![]() |
fml
0.1-0
Fused Matrix Library
|
Vector class for data held on a single CPU. More...
#include <cpuvec.hh>
Public Member Functions | |
cpuvec () | |
Construct vector object with no internal allocated storage. More... | |
cpuvec (len_t size) | |
Construct vector object with no internal allocated storage. More... | |
cpuvec (T *data, len_t size, bool free_on_destruct=false) | |
Construct vector object with inherited data. Essentially the same as using the minimal constructor and immediately calling the inherit() method. More... | |
cpuvec (const cpuvec &x) | |
void | resize (len_t size) |
Resize the internal object storage. More... | |
void | inherit (T *data, len_t size, bool free_on_destruct=false) |
Set the internal object storage to the specified array. More... | |
cpuvec< T > | dupe () const |
Duplicate the object in a deep copy. | |
void | print (uint8_t ndigits=4, bool add_final_blank=true) const |
Copy data from a CPU object to another. More... | |
void | info () const |
Print some brief information about the object. | |
void | fill_zero () |
Set all values to zero. | |
void | fill_val (const T v) |
Set all values to input value. More... | |
void | fill_linspace (const T start, const T stop) |
Set values to linearly spaced numbers. More... | |
void | scale (const T s) |
Multiply all values by the input value. More... | |
void | rev () |
Reverse the vector. | |
T | sum () |
Sum the vector. | |
T | get (const len_t i) const |
Get the specified value. More... | |
void | set (const len_t i, const T v) |
Set the storage at the specified index with the provided value. More... | |
bool | operator== (const cpuvec< T > &x) const |
See if the two objects are the same. More... | |
bool | operator!= (const cpuvec< T > &x) const |
See if the two objects are not the same. Uses same internal logic as the == method. More... | |
cpuvec< T > & | operator= (const cpuvec< T > &x) |
Operator that sets the LHS to a shallow copy of the input. Desctruction of the LHS object will not result in the internal array storage being freed. More... | |
void | fill_linspace (const int start, const int stop) |
![]() | |
len_t | size () const |
Number of elements in the vector. | |
T * | data_ptr () |
Pointer to the internal array. | |
T * | data_ptr () const |
Additional Inherited Members | |
![]() | |
bool | should_free () const |
void | check_index (const len_t i) const |
void | printval (const T val, uint8_t ndigits) const |
void | printval (const int val, uint8_t ndigits) const |
![]() | |
len_t | _size |
T * | data |
bool | free_data |
Vector class for data held on a single CPU.
T | should be 'int', 'float' or 'double'. |
Construct vector object with no internal allocated storage.
Construct vector object with no internal allocated storage.
[in] | size | Number elements of the vector. |
runtime_error
exception will be thrown.Construct vector object with inherited data. Essentially the same as using the minimal constructor and immediately calling the inherit()
method.
[in] | data_ | Storage array. |
[in] | size | Number elements of the array. |
[in] | free_on_destruct | Should the inherited array data_ be freed when the vector object is destroyed? |
void cpuvec< REAL >::fill_linspace | ( | const T | start, |
const T | stop | ||
) |
Set values to linearly spaced numbers.
[in] | start,stop | Beginning/ending numbers. |
void cpuvec< T >::fill_val | ( | const T | v | ) |
Set all values to input value.
[in] | v | Value to set all data values to. |
T cpuvec< T >::get | ( | const len_t | i | ) | const |
Get the specified value.
[in] | i | The index of the desired value, 0-indexed. |
void cpuvec< T >::inherit | ( | T * | data, |
len_t | size, | ||
bool | free_on_destruct = false |
||
) |
Set the internal object storage to the specified array.
[in] | data | Value storage. |
[in] | size | Length of the vector. Should match the length of the input data . |
[in] | free_on_destruct | Should the object destructor free the internal array data ? |
See if the two objects are not the same. Uses same internal logic as the ==
method.
[in] | Comparison | object. |
Operator that sets the LHS to a shallow copy of the input. Desctruction of the LHS object will not result in the internal array storage being freed.
[in] | x | Setter value. |
See if the two objects are the same.
[in] | Comparison | object. |
false
is necessarily returned. Next, if the pointer to the internal storage arrays match, then true
is necessarily returned. Otherwise the objects are compared value by value. void cpuvec< T >::print | ( | uint8_t | ndigits = 4 , |
bool | add_final_blank = true |
||
) | const |
Copy data from a CPU object to another.
[in] | ndigits | Number of decimal digits to print. |
[in] | add_final_blank | Should a final blank line be printed? |
void cpuvec< T >::resize | ( | len_t | size | ) |
Resize the internal object storage.
[in] | size | Length of the vector needed. |
runtime_error
exception will be thrown. void cpuvec< T >::scale | ( | const T | s | ) |
Multiply all values by the input value.
[in] | s | Scaling value. |
void cpuvec< T >::set | ( | const len_t | i, |
const T | v | ||
) |
Set the storage at the specified index with the provided value.
[in] | i | The index of the desired value, 0-indexed. |
[in] | v | Setter value. |