Matrix of fixed dimension.
More...
#include "Imagine/Common.h"
|
| FMatrix () |
| Empty constructor. More...
|
|
| FMatrix (const T &v) |
| Constructor with constant value. More...
|
|
| FMatrix (const T t[M *N]) |
| Constructor from C array. More...
|
|
| FMatrix (const T t[M][N]) |
| Constructor from bidim C array. More...
|
|
template<typename T2 > |
| FMatrix (const FMatrix< T2, M, N > &A) |
| Copy constructor Constructs from another FMatrix (with a possibly different type) More...
|
|
const T * | data () const |
| Data pointer (read). More...
|
|
T * | data () |
| Data pointer (write). More...
|
|
FMatrix & | fill (const T &v) |
| Filling. More...
|
|
FVector< T, M > | getCol (int j) const |
| Get column. More...
|
|
FVector< T, N > | getRow (int i) const |
| Get row. More...
|
|
int | ncol () const |
| Number of columns. More...
|
|
int | nrow () const |
| Number of rows. More...
|
|
bool | operator!= (const FMatrix &B) const |
| Inequality test. More...
|
|
const T & | operator() (int i, int j) const |
| Read access. More...
|
|
T & | operator() (int i, int j) |
| Write access. More...
|
|
FMatrix | operator* (T s) const |
| Scalar multiplication. More...
|
|
template<int O> |
FMatrix< T, M, O > | operator* (const FMatrix< T, N, O > &B) const |
| Product. More...
|
|
FVector< T, M > | operator* (const FVector< T, N > &v) const |
| Product with vector. More...
|
|
FMatrix & | operator*= (T s) |
| Scalar in place multiplication. More...
|
|
FMatrix | operator+ (const FMatrix &B) const |
| Addition. More...
|
|
FMatrix | operator+ (T s) const |
| Scalar Addition. More...
|
|
FMatrix & | operator+= (const FMatrix &B) |
| In place Addition. More...
|
|
FMatrix & | operator+= (T s) |
| Scalar in place Addition. More...
|
|
FMatrix | operator- (const FMatrix &B) const |
| Substraction. More...
|
|
FMatrix | operator- (T s) const |
| Scalar Substraction. More...
|
|
FMatrix | operator- () const |
| Opposite. More...
|
|
FMatrix & | operator-= (const FMatrix &B) |
| In place Substraction. More...
|
|
FMatrix & | operator-= (T s) |
| Scalar in place substractrion. More...
|
|
FMatrix | operator/ (T s) const |
| Scalar division. More...
|
|
FMatrix & | operator/= (T s) |
| Scalar in place division. More...
|
|
template<typename T2 > |
FMatrix & | operator= (const FMatrix< T2, M, N > &B) |
| Assignment. More...
|
|
bool | operator== (const FMatrix &B) const |
| Equality test. More...
|
|
const T & | operator[] (int k) const |
| 1D read access. More...
|
|
T & | operator[] (int k) |
| 1D write access. More...
|
|
FMatrix & | setCol (int j, const FVector< T, M > &v) |
| Set column. More...
|
|
FMatrix & | setRow (int i, const FVector< T, N > &v) |
| Set row. More...
|
|
int | size () const |
| Size. More...
|
|
|
T | _data [M *N] |
| internal storage.
|
|
template<typename T, int M, int N>
class Imagine::FMatrix< T, M, N >
Fixed size vectors.
- Parameters
-
T | value type |
M,N | dimensions (M=rows N=columns) |
- Examples:
- Common/test/test.cpp, Graphics/test/test.cpp, and LinAlg/test/test.cpp.
◆ FMatrix() [1/5]
template<typename T, int M, int N>
Constructs an uninitialized MxN matrix of elements of type T
◆ FMatrix() [2/5]
template<typename T, int M, int N>
Constructs an MxN matrix of elements of type T, each initialized to v
- Parameters
-
v | value used for initialization |
FMatrix<double,2,3> B(1.5);
◆ FMatrix() [3/5]
template<typename T, int M, int N>
Constructs an MxN matrix of elements of type T, and copies values to it. t contains elements (0,0), (1,0), ...
- Parameters
-
t | C array used for initialization |
double t1[6]={1,2,3,4,5,6};
FMatrix<double,2,3> C(t1);
◆ FMatrix() [4/5]
template<typename T, int M, int N>
Constructs an MxN matrix of elements of type T, and copies values to it
- Parameters
-
t | C bidimensional array used for initialization |
double t2[2][3]={{1,2,3},{4,5,6}};
FMatrix<double,2,3> D(t2);
◆ FMatrix() [5/5]
template<typename T, int M, int N>
template<typename T2 >
- Parameters
-
A | FMatrix to be copied (has to be of the same dimension) |
- Template Parameters
-
FMatrix<double,2,3> Ed(D);
FMatrix<int,2,3> Ei(D);
◆ CrossProd()
template<typename T, int M, int N>
Matrix corresponding to a 3D cross product, i.e. such that for all vector w, P*w gives v^w
- Parameters
-
- Returns
- matrix
FVector<double,3> v(1,2,3);
FMatrix<double,3,3> P;
◆ data() [1/2]
template<typename T, int M, int N>
Pointer to data for reading
- Returns
- const pointer to FMatrix elements. Element (i,j) is in position i+M*j.
◆ data() [2/2]
template<typename T, int M, int N>
Pointer to data for writing
- Returns
- Pointer to FMatrix elements. Element (i,j) is in position i+M*j.
◆ fill()
template<typename T, int M, int N>
Fills with constant value
- Parameters
-
v | value to be copied to each element |
- Returns
- self reference
◆ getCol()
template<typename T, int M, int N>
Returns column of index j
- Parameters
-
- Returns
- column vector
◆ getRow()
template<typename T, int M, int N>
Returns row of index i
- Parameters
-
- Returns
- row vector
◆ Identity()
template<typename T, int M, int N>
Identify Matrix
- Returns
- identity
◆ ncol()
template<typename T, int M, int N>
Number of columns
- Returns
- N
◆ nrow()
template<typename T, int M, int N>
◆ operator!=()
template<typename T, int M, int N>
Inequality test (component wise)
- Parameters
-
B | FMatrix for comparison (should be of same dims) |
- Returns
- true if *this does not equal B
if (A!=B) cout << "A is different from B" << endl;
◆ operator()() [1/2]
template<typename T, int M, int N>
Reads element (i,j)
- Parameters
-
- Returns
- const reference to element (i,j)
◆ operator()() [2/2]
template<typename T, int M, int N>
Writes element (i,j)
- Parameters
-
- Returns
- Reference to element (i,j)
◆ operator*() [1/3]
template<typename T, int M, int N>
Multiplies each element by a scalar
- Parameters
-
- Returns
- Result
◆ operator*() [2/3]
template<typename T, int M, int N>
template<int O>
Matrix matrix product
- Parameters
-
- Returns
- *this * B
◆ operator*() [3/3]
template<typename T, int M, int N>
Matrix vector product
- Parameters
-
- Returns
- (this) v
◆ operator*=()
template<typename T, int M, int N>
Multiplies each element by a scalar
- Parameters
-
- Returns
- self reference
◆ operator+() [1/2]
template<typename T, int M, int N>
Addition of two FMatrix
- Parameters
-
- Returns
- sum
◆ operator+() [2/2]
template<typename T, int M, int N>
Adds a scalar to each element
- Parameters
-
s | Scalar to be added to myself |
- Returns
- sum
◆ operator+=() [1/2]
template<typename T, int M, int N>
In place Addition of FMatrix
- Parameters
-
- Returns
- self reference
◆ operator+=() [2/2]
template<typename T, int M, int N>
Adds a scalar to each own element
- Parameters
-
s | Scalar to be added to myself |
- Returns
- self reference
◆ operator-() [1/3]
template<typename T, int M, int N>
Substraction of two FMatrix
- Parameters
-
B | FMatrix to be substracted from myself |
- Returns
- difference
◆ operator-() [2/3]
template<typename T, int M, int N>
Substracts a scalar to each element
- Parameters
-
s | Scalar to be substracted from myself |
- Returns
- difference
◆ operator-() [3/3]
template<typename T, int M, int N>
Opposite of a FMatrix
- Returns
- Opposite
◆ operator-=() [1/2]
template<typename T, int M, int N>
In place Substraction of FMatrix
- Parameters
-
B | FMatrix to be substracted from myself |
- Returns
- self reference
◆ operator-=() [2/2]
template<typename T, int M, int N>
Subtracts a scalar to each own element
- Parameters
-
s | Scalar to be substracted from myself |
- Returns
- self reference
◆ operator/()
template<typename T, int M, int N>
Divides each element by a scalar
- Parameters
-
- Returns
- Result
◆ operator/=()
template<typename T, int M, int N>
Divides each element by a scalar
- Parameters
-
- Returns
- self reference
◆ operator=()
template<typename T, int M, int N>
template<typename T2 >
Assigns from another FMatrix (of possibly different type but same dimension)
- Parameters
-
- Template Parameters
-
- Returns
- self reference
◆ operator==()
template<typename T, int M, int N>
Equality test (component wise)
- Parameters
-
B | FMatrix for comparison (should be of same dims) |
- Returns
- true if *this equals B
if (A==B) cout << "A equals B" << endl;
◆ operator[]() [1/2]
template<typename T, int M, int N>
Reads element at position k. Element (i,j) is at position i+M*j
- Parameters
-
- Returns
- const ref to element at position k
◆ operator[]() [2/2]
template<typename T, int M, int N>
Writes element at position k. Element (i,j) is at position i+M*j
- Parameters
-
- Returns
- Reference to element at position k
◆ setCol()
template<typename T, int M, int N>
Sets column of index j
- Parameters
-
- Returns
- self reference
◆ setRow()
template<typename T, int M, int N>
Sets row of index i
- Parameters
-
- Returns
- self reference
◆ size()
template<typename T, int M, int N>
Total dimension
- Returns
- M*N
◆ Zero()
template<typename T, int M, int N>
◆ norm
template<typename T, int M, int N>
T norm |
( |
const FMatrix< T, M, N > & |
A | ) |
|
|
friend |
Frobenius norm (provided sqrt is available for T)
- Parameters
-
- Returns
- norm
◆ norm2
template<typename T, int M, int N>
T norm2 |
( |
const FMatrix< T, M, N > & |
A | ) |
|
|
friend |
Squared Frobenius norm
- Parameters
-
- Returns
- squared norm
◆ operator<<
template<typename T, int M, int N>
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const FMatrix< T, M, N > & |
A |
|
) |
| |
|
friend |
Writes FMatrix to stream
- Parameters
-
- Returns
- updated stream
out.open("tmp.txt");
out << A << endl;
◆ operator>>
template<typename T, int M, int N>
std::istream& operator>> |
( |
std::istream & |
in, |
|
|
FMatrix< T, M, N > & |
A |
|
) |
| |
|
friend |
Reads FMatrix from stream
- Parameters
-
- Returns
- updated stream
in.open("tmp.txt");
in >> A;
◆ read
template<typename T, int M, int N>
void read |
( |
std::istream & |
in, |
|
|
FMatrix< T, M, N > & |
A |
|
) |
| |
|
friend |
Reads FMatrix from binary stream
- Parameters
-
ifstream in("tmp.bin",ios::binary);
◆ write
template<typename T, int M, int N>
void write |
( |
std::ostream & |
out, |
|
|
const FMatrix< T, M, N > & |
A |
|
) |
| |
|
friend |
Writes FMatrix to binary stream
- Parameters
-
ofstream out("tmp.bin",ios::binary);
The documentation for this class was generated from the following file:
- /home/pascal/Ponts/svn/ImagineQt/Imagine/Common/src/Imagine/Common/FMatrix.h