gslcpp
Modern-C++ Wrapper for GSL
|
Constructor-type for vector-by-reference whose storage is not owned by instance of view. More...
#include <vector-view.hpp>
Public Types | |
using | P = v_iface< T, S, v_view > |
Type of ancestor. | |
![]() | |
enum | |
using | E = T |
Element-type needed by gsl::v_iterator<v_iface>. | |
using | iterator = v_iterator< v_iface > |
Type of iterator that points to mutable element. | |
using | const_iterator = v_iterator< v_iface const > |
Type of iterator that points to immutable element. | |
Public Member Functions | |
vector_view (T *b, size_t n, size_t s=1) | |
Initialize view of standard (decayed) C-array. More... | |
vector_view (T(&b)[S]) | |
Initialize view of non-decayed C-array. More... | |
![]() | |
iterator | begin () |
Iterator that points to first element. More... | |
const_iterator | begin () const |
Iterator that points to first element. More... | |
iterator | end () |
Iterator that points to element just past last element. More... | |
const_iterator | end () const |
Iterator that points to element just past last element. More... | |
size_t | size () const |
Size of vector. More... | |
T * | data () |
Pointer to first element in vector. More... | |
const T * | data () const |
Pointer to first element in immutable vector. More... | |
T | get (size_t i) const |
Read element with bounds-checking. More... | |
void | set (size_t i, T const &x) |
Write element with bounds-checking. More... | |
const T & | operator[] (size_t i) const |
Read element without bounds-checking. More... | |
T & | operator[] (size_t i) |
Write element without bounds-checking. More... | |
T * | ptr (size_t i) |
Retrieve pointer to i th element with bounds-checking. More... | |
const T * | ptr (size_t i) const |
Retrieve pointer to i th element with bounds-checking. More... | |
void | set_all (T const &x) |
Set every element. More... | |
void | set_zero () |
Set every element to zero. | |
int | set_basis (size_t i) |
Set element at offset i to unity and every other element to zero. More... | |
int | fwrite (FILE *f) const |
Write non-portable binary-image of vector to file. More... | |
int | fread (FILE *f) |
Read non-portable binary-image of vector from file. More... | |
int | fprintf (FILE *flp, char const *fmt) const |
Write ASCII-formatted representation of vector to file. More... | |
int | fscanf (FILE *f) |
Read ASCII-formatted representation of vector from file. More... | |
v_iface< element_t< T >, N, v_view > | real () |
View of real-part of complex vector. More... | |
v_iface< element_t< T > const, N, v_view > | real () const |
View of real-part of complex vector. More... | |
v_iface< element_t< T >, N, v_view > | imag () |
View of imaginary-part of complex vector. More... | |
v_iface< element_t< T > const, N, v_view > | imag () const |
View of imaginary-part of complex vector. More... | |
v_iface< T, N, v_view > | subvector (size_t n, size_t i=0, size_t s=1) |
View of subvector of vector. More... | |
v_iface< T const, N, v_view > | subvector (size_t n, size_t i=0, size_t s=1) const |
View of subvector of vector. More... | |
v_iface< T, N, v_view > | view () |
View of vector. More... | |
v_iface< T const, N, v_view > | view () const |
View of vector. More... | |
int | swap_elements (size_t i, size_t j) |
Swap elements within this vector. More... | |
int | reverse () |
Reverse order of elements. More... | |
int | add (v_iface< T, ON, OV > const &b) |
Add contents of b into this vector in place. More... | |
int | sub (v_iface< T, ON, OV > const &b) |
Subtract contents of b from this vector in place. More... | |
int | mul (v_iface< T, ON, OV > const &b) |
Multiply contents of b into this vector in place. More... | |
int | div (v_iface< T, ON, OV > const &b) |
Divide contents of b into this vector in place. More... | |
v_iface & | operator+= (v_iface< T, ON, OV > const &b) |
Add contents of b into this vector in place. More... | |
v_iface & | operator+= (T const &x) |
Add constant into each element of this vector in place. More... | |
v_iface & | operator-= (v_iface< T, ON, OV > const &b) |
Subtract contents of b from this vector in place. More... | |
v_iface & | operator*= (v_iface< T, ON, OV > const &b) |
Multiply contents of b into this vector in place. More... | |
v_iface & | operator*= (T const &x) |
Multiply scalar into this vector in place. More... | |
v_iface & | operator/= (v_iface< T, ON, OV > const &b) |
Divide contents of b into this vector in place. More... | |
v_iface & | operator= (v_iface< T, ON, OV > const &b) |
Copy contents of b into this vector. More... | |
v_iface & | operator= (v_iface const &b) |
Copy contents of b into this vector. More... | |
v_iface (v_iface &&)=default | |
Enable move-constructor in gsl::v_stor to work. | |
int | scale (T const &x) |
Multiply scalar into this vector in place. More... | |
int | add_constant (T const &x) |
Add constant into each element of this vector in place. More... | |
T | sum () const |
Sum of elements. More... | |
T | max () const |
Greatest value of any element. More... | |
T | min () const |
Least value of any element. More... | |
void | minmax (T &min, T &max) const |
Greatest value and least value of any element. More... | |
size_t | max_index () const |
Offset of greatest value. More... | |
size_t | min_index () const |
Offset of least value. More... | |
void | minmax_index (size_t &imin, size_t &imax) const |
Offset of least value and offset of greatest value. More... | |
bool | isnull () const |
True only if every element have zero value. More... | |
bool | ispos () const |
True only if every element be positive. More... | |
bool | isneg () const |
True only if every element be negative. More... | |
bool | isnonneg () const |
True only if every element be non-negative. More... | |
![]() | |
auto * | v () |
Reference to GSL's interface to vector. More... | |
const auto * | v () const |
Reference to GSL's interface to vector. More... | |
v_view (w_vector_view< T > const &v) | |
Constructor called by TBS. More... | |
auto & | cview () const |
GSL's native, C-language interface to vector-view. More... | |
Constructor-type for vector-by-reference whose storage is not owned by instance of view.
Despite its name, vector_view allows both viewing and modifying data that it refers to. These data are presented as if they were in a virtual vector represented by the intance.
vector_view has its interface to storage given by gsl::v_view, and most of the ordinary vector-interface is given by gsl::v_iface.
vector_view inherits these and provides template-constructors for an instance of type gsl::v_iface<T, S, v_view>.
Template-value-parameter S
indicates the number of elements in the vector at compile-time. If S
be zero, then the number of elements in the vector is determined at run-time.
When using vector_view, one typically does not need to specify template-parameters:
T | Type of each element in vector. |
S | Compile-time number of elements (0 for number set at run-time). |
Definition at line 64 of file vector-view.hpp.
|
inline |
Initialize view of standard (decayed) C-array.
Arguments are ordered differently from those given to gsl_vector_viewiew_array_with_stride(). Putting stride at end allows it to have default value of 1.
b | Pointer to first element of array and of view. |
n | Number of elements in view. |
s | Stride of elements relative to array. |
Definition at line 77 of file vector-view.hpp.
|
inline |
Initialize view of non-decayed C-array.
b | Reference to non-decayed C-array. |
Definition at line 81 of file vector-view.hpp.