Marsyas
0.6.0-alpha
|
Vector of mrs_real values. More...
#include <realvec.h>
Public Member Functions | |
realvec & | operator= (const realvec &a) |
realvec () | |
constructor | |
realvec (mrs_natural size) | |
realvec (mrs_natural rows, mrs_natural cols, mrs_real value=0.0) | |
realvec (const realvec &a) | |
void | shuffle () |
~realvec () | |
Memory allocation | |
void | allocate (mrs_natural size) |
void | allocate (mrs_natural rows, mrs_natural cols) |
void | create (mrs_natural size) |
allocate(size) + fill with zeros | |
void | create (mrs_natural rows, mrs_natural cols) |
allocate(rows,cols) + fill with zeros | |
void | create (mrs_real val, mrs_natural rows, mrs_natural cols) |
allocate(rows,cols) + fill with val | |
void | stretch (mrs_natural rows, mrs_natural cols) |
allocate(size) + keep old vals. May also be used to shrink realvec. | |
void | stretch (mrs_natural size) |
allocate(size) + keep old vals. May also be used to shrink realvec. | |
void | stretchWrite (const mrs_natural pos, const mrs_real val) |
write to array, stretching the array if necessary | |
void | stretchWrite (const mrs_natural r, const mrs_natural c, const mrs_real val) |
write to array, stretching the array if necessary | |
Modify values in array | |
void | setval (mrs_natural start, mrs_natural end, mrs_real val) |
set all entries to val | |
void | setval (mrs_real val) |
set all entries to val | |
void | appendRealvec (const realvec newValues) |
other | |
void | apply (mrs_real(*func)(mrs_real)) |
apply a given function to all the elements | |
Getting information | |
mrs_natural | getSize () const |
mrs_natural | getCols () const |
mrs_natural | getRows () const |
realvec | getSubVector (mrs_natural startPos, mrs_natural length) const |
extracts a subset of a realvec. One-dimensional realvecs only. | |
mrs_real * | getData () const |
dirty for easy integration | |
Vector Operations | |
bool | operator!= (const realvec &v1) const |
bool | operator== (const realvec &v1) const |
realvec & | operator+= (const realvec &vec) |
realvec & | operator-= (const realvec &vec) |
realvec & | operator*= (const realvec &vec) |
realvec & | operator/= (const realvec &vec) |
template<typename T > | |
realvec & | operator*= (const T &rhs) |
template<typename T > | |
realvec & | operator/= (const T &rhs) |
template<typename T > | |
realvec & | operator+= (const T &rhs) |
template<typename T > | |
realvec & | operator-= (const T &rhs) |
Item access | |
mrs_real & | operator() (const mrs_natural i) |
mrs_real | operator() (const mrs_natural i) const |
mrs_real & | operator() (const mrs_natural r, const mrs_natural c) |
mrs_real | operator() (const mrs_natural r, const mrs_natural c) const |
mrs_real | getValueFenced (const mrs_natural i) const |
Get the value at index i or raise Exception when out of bounds. | |
mrs_real | getValueFenced (const mrs_natural r, const mrs_natural c) const |
Get the value at position (r, c) or raise Exception when out of bounds. | |
mrs_real & | getValueFenced (const mrs_natural i) |
Get reference to value at index i or raise Exception when out of bounds. | |
mrs_real & | getValueFenced (const mrs_natural r, const mrs_natural c) |
Get reference to value at position (r, c) or raise Exception when out of bounds. | |
Indexing | |
realvec | operator() (std::string r, std::string c) |
matlab-like | |
realvec | operator() (std::string r) |
matlab-like | |
void | getRow (const mrs_natural r, realvec &res) const |
vector indexing | |
void | getCol (const mrs_natural c, realvec &res) const |
vector indexing | |
void | getSubMatrix (const mrs_natural r, const mrs_natural c, realvec &res) |
get submatrix | |
void | setRow (const mrs_natural r, const realvec src) |
void | setCol (const mrs_natural c, const realvec src) |
void | setSubMatrix (const mrs_natural r, const mrs_natural c, const realvec src) |
Observations statics | |
void | meanObs (realvec &res) const |
void | stdObs (realvec &res) const |
void | varObs (realvec &res) const |
void | normObs () |
void | normSpl (mrs_natural=0) |
void | normObsMinMax () |
void | normSplMinMax (mrs_natural=0) |
Communications | |
void | send (Communicator *com) |
mrs_natural | search (mrs_real val) |
Output functions | |
void | debug_info () |
void | dump () |
bool | write (std::string filename) const |
bool | read (std::string filename) |
void | dumpDataOnly (std::ostream &o=std::cout, std::string columnSep=" ", std::string rowSep="\n") const |
Dump the realvec data (without header) to an output stream. | |
bool | readText (std::string filename) |
input function for line-separated text files | |
bool | writeText (std::string filename) |
output function for line-separated text files | |
marsyas_EXPORT friend std::ostream & | operator<< (std::ostream &, const realvec &) |
marsyas_EXPORT friend std::istream & | operator>> (std::istream &, realvec &) |
Vector/Matrix Algebra and Statistics | |
mrs_real | maxval (mrs_natural *index=NULL) const |
mrs_real | minval () const |
mrs_real | mean () const |
mrs_real | median () const |
mrs_real | sum () const |
mrs_real | std () const |
mrs_real | var () const |
void | sort () |
void | abs () |
void | sqr () |
void | sqroot () |
void | norm () |
void | normMaxMin () |
void | pow (mrs_real exp) |
void | norm (mrs_real mean, mrs_real std) |
void | renorm (mrs_real old_mean, mrs_real old_std, mrs_real new_mean, mrs_real new_std) |
mrs_natural | invert (realvec &res) |
void | transpose () |
void | fliplr () |
void | flipud () |
void | covariance (realvec &res) const |
void | covariance2 (realvec &res) const |
void | correlation (realvec &res) const |
mrs_real | trace () const |
mrs_real | det () const |
static void | matrixMulti (const mrs_realvec &a, const mrs_realvec &b, mrs_realvec &out) |
matrix Multiplication |
Vector of mrs_real values.
Array (vector in the numerical sense) of mrs_real values. Basic arithmetic operations and statistics are supported.
The values of the realvec are stored in "column-major" order, which means that the data is stored per column, which are in turn stored in sequence. This has practical consequences for the optimal accessing order for the realvec values. Accessing array elements that are contiguous in memory is usually faster than accessing elements which are not, due to caching. If the intended processing allows this, it is for example better to access the values with the column and row loops embedded like
for (int c = 0; c < cols_; ++c) { for (int r = 0; r < rows_ ; ++r) { // do stuff with realvec(r, c); } }
than with the column and row loop swapped.
realvec | ( | ) |
constructor
Definition at line 39 of file realvec.cpp.
realvec | ( | mrs_natural | size | ) | [explicit] |
Definition at line 55 of file realvec.cpp.
realvec | ( | mrs_natural | rows, |
mrs_natural | cols, | ||
mrs_real | value = 0.0 |
||
) | [explicit] |
Definition at line 65 of file realvec.cpp.
Definition at line 80 of file realvec.cpp.
~realvec | ( | ) |
Definition at line 49 of file realvec.cpp.
void abs | ( | ) |
Definition at line 521 of file realvec.cpp.
void allocate | ( | mrs_natural | size | ) |
Definition at line 463 of file realvec.cpp.
void allocate | ( | mrs_natural | rows, |
mrs_natural | cols | ||
) |
Definition at line 476 of file realvec.cpp.
void appendRealvec | ( | const realvec | newValues | ) |
appends values from the newValues realvec. Resizes the original realvec to make space for the new values. One-dimensional realvecs only.
Definition at line 125 of file realvec.cpp.
apply a given function to all the elements
Definition at line 503 of file realvec.cpp.
void correlation | ( | realvec & | res | ) | const |
Definition at line 1444 of file realvec.cpp.
void covariance | ( | realvec & | res | ) | const |
Definition at line 1485 of file realvec.cpp.
void covariance2 | ( | realvec & | res | ) | const |
Definition at line 1539 of file realvec.cpp.
void create | ( | mrs_natural | size | ) |
allocate(size) + fill with zeros
Definition at line 427 of file realvec.cpp.
void create | ( | mrs_natural | rows, |
mrs_natural | cols | ||
) |
allocate(rows,cols) + fill with zeros
Definition at line 436 of file realvec.cpp.
void create | ( | mrs_real | val, |
mrs_natural | rows, | ||
mrs_natural | cols | ||
) |
allocate(rows,cols) + fill with val
Definition at line 446 of file realvec.cpp.
void debug_info | ( | ) |
Definition at line 283 of file realvec.cpp.
Definition at line 1605 of file realvec.cpp.
void dump | ( | ) |
Definition at line 784 of file realvec.cpp.
void dumpDataOnly | ( | std::ostream & | o = std::cout , |
std::string | columnSep = " " , |
||
std::string | rowSep = "\n" |
||
) | const |
Dump the realvec data (without header) to an output stream.
Dump the realvec data (only the data, no header info ) to an outputstream. Use the given column and row separators between columns and rows respectively.
Definition at line 847 of file realvec.cpp.
void fliplr | ( | ) |
Definition at line 162 of file realvec.cpp.
void flipud | ( | ) |
Definition at line 176 of file realvec.cpp.
void getCol | ( | const mrs_natural | c, |
realvec & | res | ||
) | const |
vector indexing
Definition at line 1129 of file realvec.cpp.
mrs_natural getCols | ( | ) | const |
Definition at line 271 of file realvec.cpp.
dirty for easy integration
Definition at line 119 of file realvec.cpp.
void getRow | ( | const mrs_natural | r, |
realvec & | res | ||
) | const |
vector indexing
Definition at line 1105 of file realvec.cpp.
mrs_natural getRows | ( | ) | const |
Definition at line 265 of file realvec.cpp.
mrs_natural getSize | ( | ) | const |
Definition at line 277 of file realvec.cpp.
void getSubMatrix | ( | const mrs_natural | r, |
const mrs_natural | c, | ||
realvec & | res | ||
) |
get submatrix
Definition at line 1152 of file realvec.cpp.
realvec getSubVector | ( | mrs_natural | startPos, |
mrs_natural | length | ||
) | const |
extracts a subset of a realvec. One-dimensional realvecs only.
Definition at line 136 of file realvec.cpp.
mrs_real getValueFenced | ( | const mrs_natural | i | ) | const |
Get the value at index i or raise Exception when out of bounds.
i | the index to get the value at. |
std::out_of_range | is thrown when the index is out of bounds. |
Definition at line 1754 of file realvec.cpp.
mrs_real getValueFenced | ( | const mrs_natural | r, |
const mrs_natural | c | ||
) | const |
Get the value at position (r, c) or raise Exception when out of bounds.
r | the row index of the position to get the value from. |
c | the column index of the position to get the value from. |
std::out_of_range | is thrown when the row or column index are out of bounds. |
Definition at line 1773 of file realvec.cpp.
mrs_real & getValueFenced | ( | const mrs_natural | i | ) |
Get reference to value at index i or raise Exception when out of bounds.
Returned reference can be used as left hand side value (lvalue).
i | the index to get the value at. |
std::out_of_range | is thrown when the index is out of bounds. |
Definition at line 1792 of file realvec.cpp.
mrs_real & getValueFenced | ( | const mrs_natural | r, |
const mrs_natural | c | ||
) |
Get reference to value at position (r, c) or raise Exception when out of bounds.
Returned reference can be used as left hand side value (lvalue).
r | the row index of the position to get the value from. |
c | the column index of the position to get the value from. |
std::out_of_range | is thrown when the row or column index are out of bounds. |
Definition at line 1812 of file realvec.cpp.
mrs_natural invert | ( | realvec & | res | ) |
Definition at line 595 of file realvec.cpp.
void matrixMulti | ( | const mrs_realvec & | a, |
const mrs_realvec & | b, | ||
mrs_realvec & | out | ||
) | [static] |
matrix Multiplication
a | first input matrix |
b | second input matrix |
out | preallocated realvec for the output |
std::out_of_range | is thrown when the index is out of bounds. |
Definition at line 1722 of file realvec.cpp.
mrs_real maxval | ( | mrs_natural * | index = NULL | ) | const |
Definition at line 1222 of file realvec.cpp.
Definition at line 201 of file realvec.cpp.
Definition at line 1252 of file realvec.cpp.
Definition at line 190 of file realvec.cpp.
Definition at line 1240 of file realvec.cpp.
void norm | ( | ) |
Definition at line 539 of file realvec.cpp.
Definition at line 575 of file realvec.cpp.
void normMaxMin | ( | ) |
Definition at line 551 of file realvec.cpp.
void normObs | ( | ) |
Definition at line 1326 of file realvec.cpp.
void normObsMinMax | ( | ) |
Definition at line 1351 of file realvec.cpp.
void normSpl | ( | mrs_natural | index = 0 | ) |
Definition at line 1380 of file realvec.cpp.
void normSplMinMax | ( | mrs_natural | index = 0 | ) |
Definition at line 1412 of file realvec.cpp.
bool operator!= | ( | const realvec & | v1 | ) | const |
Definition at line 1657 of file realvec.cpp.
mrs_real & operator() | ( | const mrs_natural | i | ) | [inline] |
mrs_real operator() | ( | const mrs_natural | i | ) | const [inline] |
mrs_real & operator() | ( | const mrs_natural | r, |
const mrs_natural | c | ||
) | [inline] |
mrs_real operator() | ( | const mrs_natural | r, |
const mrs_natural | c | ||
) | const [inline] |
realvec operator() | ( | std::string | r, |
std::string | c | ||
) |
matlab-like
Definition at line 985 of file realvec.cpp.
realvec operator() | ( | std::string | r | ) |
matlab-like
Definition at line 1063 of file realvec.cpp.
Definition at line 1687 of file realvec.cpp.
Definition at line 1663 of file realvec.cpp.
Definition at line 1675 of file realvec.cpp.
Definition at line 1699 of file realvec.cpp.
Definition at line 95 of file realvec.cpp.
bool operator== | ( | const realvec & | v1 | ) | const |
Definition at line 1640 of file realvec.cpp.
Definition at line 530 of file realvec.cpp.
bool read | ( | std::string | filename | ) |
Definition at line 729 of file realvec.cpp.
bool readText | ( | std::string | filename | ) |
input function for line-separated text files
Definition at line 792 of file realvec.cpp.
Definition at line 584 of file realvec.cpp.
mrs_natural search | ( | mrs_real | val | ) |
Definition at line 688 of file realvec.cpp.
void send | ( | Communicator * | com | ) |
Definition at line 711 of file realvec.cpp.
void setCol | ( | const mrs_natural | c, |
const realvec | src | ||
) |
Definition at line 1195 of file realvec.cpp.
void setRow | ( | const mrs_natural | r, |
const realvec | src | ||
) |
Definition at line 1190 of file realvec.cpp.
void setSubMatrix | ( | const mrs_natural | r, |
const mrs_natural | c, | ||
const realvec | src | ||
) |
Definition at line 1200 of file realvec.cpp.
void setval | ( | mrs_natural | start, |
mrs_natural | end, | ||
mrs_real | val | ||
) |
set all entries to val
Definition at line 490 of file realvec.cpp.
set all entries to val
Definition at line 512 of file realvec.cpp.
void shuffle | ( | ) |
Definition at line 746 of file realvec.cpp.
void sort | ( | ) |
Definition at line 213 of file realvec.cpp.
void sqr | ( | ) |
Definition at line 679 of file realvec.cpp.
void sqroot | ( | ) |
Definition at line 702 of file realvec.cpp.
Definition at line 255 of file realvec.cpp.
Definition at line 1302 of file realvec.cpp.
void stretch | ( | mrs_natural | rows, |
mrs_natural | cols | ||
) |
allocate(size) + keep old vals. May also be used to shrink realvec.
Definition at line 328 of file realvec.cpp.
void stretch | ( | mrs_natural | size | ) |
allocate(size) + keep old vals. May also be used to shrink realvec.
Definition at line 291 of file realvec.cpp.
void stretchWrite | ( | const mrs_natural | pos, |
const mrs_real | val | ||
) |
write to array, stretching the array if necessary
Definition at line 376 of file realvec.cpp.
void stretchWrite | ( | const mrs_natural | r, |
const mrs_natural | c, | ||
const mrs_real | val | ||
) |
write to array, stretching the array if necessary
Definition at line 395 of file realvec.cpp.
Definition at line 219 of file realvec.cpp.
Definition at line 1586 of file realvec.cpp.
void transpose | ( | ) |
Definition at line 145 of file realvec.cpp.
Definition at line 231 of file realvec.cpp.
Definition at line 1277 of file realvec.cpp.
bool write | ( | std::string | filename | ) | const |
Definition at line 768 of file realvec.cpp.
bool writeText | ( | std::string | filename | ) |
output function for line-separated text files
Definition at line 820 of file realvec.cpp.
marsyas_EXPORT friend std::ostream& operator<< | ( | std::ostream & | o, |
const realvec & | vec | ||
) | [friend] |
Definition at line 867 of file realvec.cpp.
marsyas_EXPORT friend std::istream& operator>> | ( | std::istream & | is, |
realvec & | vec | ||
) | [friend] |
Definition at line 889 of file realvec.cpp.