18 #ifndef __utlITKSpams_h 19 #define __utlITKSpams_h 24 #include <vnl/vnl_matrix.h> 25 #include <vnl/vnl_vector.h> 34 matSpams.
resize(matVnl.rows(), matVnl.columns());
38 T
const* matVnl_data = matVnl.data_block();
39 T* matSpams_data = matSpams.
rawX();
40 if (matVnl.rows() >= matVnl.columns())
42 for (
int j = 0; j < matVnl.columns(); j += 1 )
43 cblas_copy<T>(matVnl.rows(), (T*)matVnl_data+j, matVnl.columns(), matSpams_data+j*matVnl.rows(),1);
47 for (
int i = 0; i < matVnl.rows(); i += 1 )
48 cblas_copy<T>(matVnl.columns(), (T*)matVnl_data+i*matVnl.columns(), 1, matSpams_data+i,matVnl.rows());
56 matVnl.set_size(matSpams.
m(), matSpams.
n());
60 T* matVnl_data = matVnl.data_block();
61 const T * matSpams_data = matSpams.
X();
62 if (matVnl.rows() >= matVnl.columns())
64 for (
int j = 0; j < matVnl.columns(); j += 1 )
65 cblas_copy<T>(matVnl.rows(), (T*)matSpams_data+j*matVnl.rows(),1, matVnl_data+j, matVnl.columns());
69 for (
int i = 0; i < matVnl.rows(); i += 1 )
70 cblas_copy<T>(matVnl.columns(), (T*)matSpams_data+i,matVnl.rows(), matVnl_data+i*matVnl.columns(), 1);
81 cblas_copy<T>(v.size(), v.data_block(),1, vec.
rawX(), 1);
91 cblas_copy<T>(vec.size(), v.
rawX(),1, vec.data_block(), 1);
98 result.set_size(mat.
m(), mat.
n());
103 for (
int i = 0; i < mat.
n(); i += 1 )
104 for (
int j = pB[i]; j<pE[i]; ++j)
105 result(r[j], i) = mat.
v(j);
void VnlVectorToVector(const vnl_vector< T > &v, Vector< T > &vec)
int pB(const int i) const
returns pB[i]
void VectorToVnlVector(const Vector< T > &v, vnl_vector< T > &vec)
int * pE() const
Direct access to _pE.
T * rawX() const
returns a modifiable reference of the data, DANGEROUS
int n() const
returns the size of the vector
T v(const int i) const
returns v[i]
int m() const
returns the number of columns
void SpMatrixToVnlMatrix(const SpMatrix< T > &mat, vnl_matrix< T > &result)
int n() const
Number of columns.
void resize(const int n)
resize the vector
int r(const int i) const
returns r[i]
int n() const
returns the number of rows
void MatrixToVnlMatrix(const Matrix< T > &matSpams, vnl_matrix< T > &matVnl)
void resize(int m, int n)
Resize the matrix.
void VnlMatrixToMatrix(const vnl_matrix< T > &matVnl, Matrix< T > &matSpams)
const T * X() const
return a non-modifiable reference to the data
T * rawX() const
reference a modifiable reference to the data, DANGEROUS