SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
所有成员列表 | Public 类型 | Public 成员函数 | 静态 Public 成员函数 | Public 属性 | Protected 成员函数
SGMatrix< T > Singleton Reference

详细描述

template<class T>
singleton shogun::SGMatrix< T >

shogun matrix

在文件 base/Parameter.h26 行定义.

类 SGMatrix< T > 继承关系图:
Inheritance graph
[图例]

Public 类型

typedef T Scalar
 

Public 成员函数

 SGMatrix ()
 
 SGMatrix (bool ref_counting)
 
 SGMatrix (T *m, index_t nrows, index_t ncols, bool ref_counting=true)
 
 SGMatrix (T *m, index_t nrows, index_t ncols, index_t offset)
 
 SGMatrix (index_t nrows, index_t ncols, bool ref_counting=true)
 
 SGMatrix (SGVector< T > vec)
 
 SGMatrix (SGVector< T > vec, index_t nrows, index_t ncols)
 
 SGMatrix (EigenMatrixXt &mat)
 
 operator EigenMatrixXtMap () const
 
 SGMatrix (const SGMatrix &orig)
 
virtual ~SGMatrix ()
 
T * get_column_vector (index_t col) const
 
SGVector< T > get_row_vector (index_t row) const
 
SGVector< T > get_diagonal_vector () const
 
const T & operator() (index_t i_row, index_t i_col) const
 
const T & operator[] (index_t index) const
 
T & operator() (index_t i_row, index_t i_col)
 
T & operator[] (index_t index)
 
SGMatrix< T > get ()
 
T * data () const
 
uint64_t size () const
 
bool operator== (SGMatrix< T > &other)
 
bool equals (SGMatrix< T > &other)
 
void set_const (T const_elem)
 
void zero ()
 
bool is_symmetric ()
 
max_single ()
 
SGMatrix< T > clone ()
 
void compute_few_eigenvectors (double *matrix_, double *&eigenvalues, double *&eigenvectors, int n, int il, int iu)
 
void center ()
 
void remove_column_mean ()
 
void display_matrix (const char *name="matrix") const
 
void load (CFile *loader)
 
void save (CFile *saver)
 
template<>
void zero ()
 
template<>
bool is_symmetric ()
 
template<>
bool is_symmetric ()
 
template<>
bool is_symmetric ()
 
template<>
bool is_symmetric ()
 
template<>
complex128_t max_single ()
 
template<>
void display_matrix (const bool *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const char *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const int8_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const uint8_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const int16_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const uint16_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const int32_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const uint32_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const int64_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const uint64_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const float32_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const float64_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const floatmax_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
void display_matrix (const complex128_t *matrix, int32_t rows, int32_t cols, const char *name, const char *prefix)
 
template<>
SGMatrix< char > create_identity_matrix (index_t size, char scale)
 
template<>
SGMatrix< int8_t > create_identity_matrix (index_t size, int8_t scale)
 
template<>
SGMatrix< uint8_t > create_identity_matrix (index_t size, uint8_t scale)
 
template<>
SGMatrix< bool > create_identity_matrix (index_t size, bool scale)
 
template<>
SGMatrix< int16_t > create_identity_matrix (index_t size, int16_t scale)
 
template<>
SGMatrix< uint16_t > create_identity_matrix (index_t size, uint16_t scale)
 
template<>
SGMatrix< int32_t > create_identity_matrix (index_t size, int32_t scale)
 
template<>
SGMatrix< uint32_t > create_identity_matrix (index_t size, uint32_t scale)
 
template<>
SGMatrix< int64_t > create_identity_matrix (index_t size, int64_t scale)
 
template<>
SGMatrix< uint64_t > create_identity_matrix (index_t size, uint64_t scale)
 
template<>
SGMatrix< float32_tcreate_identity_matrix (index_t size, float32_t scale)
 
template<>
SGMatrix< float64_tcreate_identity_matrix (index_t size, float64_t scale)
 
template<>
SGMatrix< floatmax_tcreate_identity_matrix (index_t size, floatmax_t scale)
 
template<>
SGMatrix< complex128_tcreate_identity_matrix (index_t size, complex128_t scale)
 
template<>
void load (CFile *loader)
 
template<>
void save (CFile *saver)
 
int32_t ref_count ()
 

静态 Public 成员函数

static T * clone_matrix (const T *matrix, int32_t nrows, int32_t ncols)
 
static void transpose_matrix (T *&matrix, int32_t &num_feat, int32_t &num_vec)
 
static void create_diagonal_matrix (T *matrix, T *v, int32_t size)
 
static SGMatrix< T > create_identity_matrix (index_t size, T scale)
 
static SGVector< float64_tcompute_eigenvectors (SGMatrix< float64_t > matrix)
 
static double * compute_eigenvectors (double *matrix, int n, int m)
 
static SGMatrix< float64_tmatrix_multiply (SGMatrix< float64_t > A, SGMatrix< float64_t > B, bool transpose_A=false, bool transpose_B=false, float64_t scale=1.0)
 
static void inverse (SGMatrix< float64_t > matrix)
 inverses square matrix in-place 更多...
 
static float64_tpinv (float64_t *matrix, int32_t rows, int32_t cols, float64_t *target=NULL)
 
static float64_t trace (float64_t *mat, int32_t cols, int32_t rows)
 
static T * get_row_sum (T *matrix, int32_t m, int32_t n)
 
static T * get_column_sum (T *matrix, int32_t m, int32_t n)
 
static void center_matrix (T *matrix, int32_t m, int32_t n)
 
static void display_matrix (const T *matrix, int32_t rows, int32_t cols, const char *name="matrix", const char *prefix="")
 
static void display_matrix (const SGMatrix< T > matrix, const char *name="matrix", const char *prefix="")
 
static SGMatrix< T > get_allocated_matrix (index_t num_rows, index_t num_cols, SGMatrix< T > pre_allocated=SGMatrix< T >())
 

Public 属性

T * matrix
 
index_t num_rows
 
index_t num_cols
 

Protected 成员函数

virtual void copy_data (const SGReferencedData &orig)
 
virtual void init_data ()
 
virtual void free_data ()
 
void copy_refcount (const SGReferencedData &orig)
 
int32_t ref ()
 
int32_t unref ()
 

成员类型定义说明

typedef T Scalar

The scalar type of the matrix

在文件 SGMatrix.h40 行定义.

构造及析构函数说明

SGMatrix ( )

Default constructor

在文件 SGMatrix.cpp30 行定义.

SGMatrix ( bool  ref_counting)

Constructor for setting reference counting while not creating the matrix in memory (use this for static SGMatrix instances)

在文件 SGMatrix.cpp36 行定义.

SGMatrix ( T *  m,
index_t  nrows,
index_t  ncols,
bool  ref_counting = true 
)

Constructor for setting params

在文件 SGMatrix.cpp42 行定义.

SGMatrix ( T *  m,
index_t  nrows,
index_t  ncols,
index_t  offset 
)

Wraps a matrix around an existing memory segment with an offset

在文件 SGMatrix.h53 行定义.

SGMatrix ( index_t  nrows,
index_t  ncols,
bool  ref_counting = true 
)

Constructor to create new matrix in memory

在文件 SGMatrix.cpp47 行定义.

SGMatrix ( SGVector< T >  vec)

Constructor for creating a SGMatrix from a SGVector with refcounting. We do not copy the data here, just the pointer to data and the ref- count object of the SGVector (i.e. vec and this share same data and ref-count object).

This constructor assumes that the vector is the column 0 in the matrix.

参数
vecThe SGVector

在文件 SGMatrix.cpp54 行定义.

SGMatrix ( SGVector< T >  vec,
index_t  nrows,
index_t  ncols 
)

Constructor for creating a SGMatrix from a SGVector with refcounting. We do not copy the data here, just the pointer to data and the ref- count object of the SGVector (i.e. vec and this share same data and ref-count object).

The number of elements in the matrix MUST be same as the number of elements in the vector

参数
vecThe SGVector
nrowsnumber of rows in the matrix
ncolsnumber of columns in the matrix

在文件 SGMatrix.cpp63 行定义.

SGMatrix ( EigenMatrixXt mat)

Wraps a matrix around the data of an Eigen3 matrix

在文件 SGMatrix.cpp85 行定义.

SGMatrix ( const SGMatrix< T > &  orig)

Copy constructor

在文件 SGMatrix.cpp78 行定义.

~SGMatrix ( )
virtual

Empty destructor

在文件 SGMatrix.cpp100 行定义.

成员函数说明

void center ( )

Centers the matrix, i.e. removes column/row mean from columns/rows

在文件 SGMatrix.cpp346 行定义.

void center_matrix ( T *  matrix,
int32_t  m,
int32_t  n 
)
static

Centers matrix (e.g. kernel matrix in feature space INPLACE

在文件 SGMatrix.cpp352 行定义.

SGMatrix< T > clone ( )

Clone matrix

在文件 SGMatrix.cpp260 行定义.

T * clone_matrix ( const T *  matrix,
int32_t  nrows,
int32_t  ncols 
)
static

Clone matrix

在文件 SGMatrix.cpp267 行定义.

SGVector< float64_t > compute_eigenvectors ( SGMatrix< float64_t matrix)
static

Compute eigenvalues and eigenvectors of symmetric matrix using LAPACK

参数
matrixsymmetric matrix to compute eigenproblem. Is overwritten and contains orthonormal eigenvectors afterwards
返回
eigenvalues vector with eigenvalues equal to number of rows in matrix

在文件 SGMatrix.cpp895 行定义.

double * compute_eigenvectors ( double *  matrix,
int  n,
int  m 
)
static

Compute eigenvalues and eigenvectors of symmetric matrix

参数
matrixoverwritten and contains n orthonormal eigenvectors
n
m
返回
eigenvalues (array of length n, to be deleted[])

在文件 SGMatrix.cpp912 行定义.

void compute_few_eigenvectors ( double *  matrix_,
double *&  eigenvalues,
double *&  eigenvectors,
int  n,
int  il,
int  iu 
)

Compute few eigenpairs of a symmetric matrix using LAPACK DSYEVR method (Relatively Robust Representations). Has at least O(n^3/3) complexity

参数
matrix_symmetric matrix
eigenvaluescontains iu-il+1 eigenvalues in ascending order (to be free'd)
eigenvectorscontains iu-il+1 orthonormal eigenvectors of given matrix column-wise (to be free'd)
ndimension of matrix
illow index of requested eigenpairs (1<=il<=n)
iuhigh index of requested eigenpairs (1<=il<=iu<=n)

在文件 SGMatrix.cpp934 行定义.

void copy_data ( const SGReferencedData orig)
protectedvirtual

overridden to copy data

实现了 SGReferencedData.

在文件 SGMatrix.cpp1027 行定义.

void copy_refcount ( const SGReferencedData orig)
protectedinherited

copy refcount

在文件 SGReferencedData.cpp55 行定义.

void create_diagonal_matrix ( T *  matrix,
T *  v,
int32_t  size 
)
static

Create diagonal matrix

在文件 SGMatrix.cpp295 行定义.

static SGMatrix<T> create_identity_matrix ( index_t  size,
scale 
)
static

Returns the identity matrix, scaled by a factor

参数
sizesize of square identity matrix
scale(optional) scaling factor
SGMatrix< char > create_identity_matrix ( index_t  size,
char  scale 
)

在文件 SGMatrix.cpp660 行定义.

SGMatrix< int8_t > create_identity_matrix ( index_t  size,
int8_t  scale 
)

在文件 SGMatrix.cpp667 行定义.

SGMatrix< uint8_t > create_identity_matrix ( index_t  size,
uint8_t  scale 
)

在文件 SGMatrix.cpp680 行定义.

SGMatrix< bool > create_identity_matrix ( index_t  size,
bool  scale 
)

在文件 SGMatrix.cpp693 行定义.

SGMatrix< int16_t > create_identity_matrix ( index_t  size,
int16_t  scale 
)

在文件 SGMatrix.cpp706 行定义.

SGMatrix< uint16_t > create_identity_matrix ( index_t  size,
uint16_t  scale 
)

在文件 SGMatrix.cpp719 行定义.

SGMatrix< int32_t > create_identity_matrix ( index_t  size,
int32_t  scale 
)

在文件 SGMatrix.cpp732 行定义.

SGMatrix< uint32_t > create_identity_matrix ( index_t  size,
uint32_t  scale 
)

在文件 SGMatrix.cpp745 行定义.

SGMatrix< int64_t > create_identity_matrix ( index_t  size,
int64_t  scale 
)

在文件 SGMatrix.cpp758 行定义.

SGMatrix< uint64_t > create_identity_matrix ( index_t  size,
uint64_t  scale 
)

在文件 SGMatrix.cpp771 行定义.

SGMatrix< float32_t > create_identity_matrix ( index_t  size,
float32_t  scale 
)

在文件 SGMatrix.cpp784 行定义.

SGMatrix< float64_t > create_identity_matrix ( index_t  size,
float64_t  scale 
)

在文件 SGMatrix.cpp797 行定义.

SGMatrix< floatmax_t > create_identity_matrix ( index_t  size,
floatmax_t  scale 
)

在文件 SGMatrix.cpp810 行定义.

SGMatrix< complex128_t > create_identity_matrix ( index_t  size,
complex128_t  scale 
)

在文件 SGMatrix.cpp823 行定义.

T* data ( ) const

The data

在文件 SGMatrix.h181 行定义.

void display_matrix ( const char *  name = "matrix") const

Display matrix

在文件 SGMatrix.cpp394 行定义.

static void display_matrix ( const T *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name = "matrix",
const char *  prefix = "" 
)
static

Display matrix (useful for debugging)

void display_matrix ( const SGMatrix< T >  matrix,
const char *  name = "matrix",
const char *  prefix = "" 
)
static

Display matrix

在文件 SGMatrix.cpp400 行定义.

void display_matrix ( const bool *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp408 行定义.

void display_matrix ( const char *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp426 行定义.

void display_matrix ( const int8_t *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp444 行定义.

void display_matrix ( const uint8_t *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp462 行定义.

void display_matrix ( const int16_t *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp480 行定义.

void display_matrix ( const uint16_t *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp498 行定义.

void display_matrix ( const int32_t *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp517 行定义.

void display_matrix ( const uint32_t *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp535 行定义.

void display_matrix ( const int64_t *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp552 行定义.

void display_matrix ( const uint64_t *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp570 行定义.

void display_matrix ( const float32_t matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp588 行定义.

void display_matrix ( const float64_t matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp606 行定义.

void display_matrix ( const floatmax_t matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp624 行定义.

void display_matrix ( const complex128_t matrix,
int32_t  rows,
int32_t  cols,
const char *  name,
const char *  prefix 
)

在文件 SGMatrix.cpp642 行定义.

bool equals ( SGMatrix< T > &  other)

Operator overload for element-wise matrix comparison. Note that only numerical data is compared

参数
othermatrix to compare with
返回
true iff all elements are equal

在文件 SGMatrix.cpp118 行定义.

void free_data ( )
protectedvirtual

overridden to free data

实现了 SGReferencedData.

在文件 SGMatrix.cpp1043 行定义.

SGMatrix<T> get ( )

Get the matrix (no copying is done here)

返回
the refcount increased matrix

在文件 SGMatrix.h175 行定义.

SGMatrix< T > get_allocated_matrix ( index_t  num_rows,
index_t  num_cols,
SGMatrix< T >  pre_allocated = SGMatrix<T>() 
)
static

Simple helper method that returns a matrix with allocated memory for a given size. A pre_allocated one can optionally be specified in order to use that. Basically just for having dimension check encapsulated.

参数
num_rowsrows of returned matrix
num_colscolumns of returned matrix
pre_allocatedoptional matrix that is returned instead of new matrix. Make sure dimensions match
返回
matrix with allocated memory of specified size

在文件 SGMatrix.cpp997 行定义.

T * get_column_sum ( T *  matrix,
int32_t  m,
int32_t  n 
)
static

Sums up all columns of a matrix and returns the resulting columnvector

在文件 SGMatrix.cpp333 行定义.

T* get_column_vector ( index_t  col) const

Get a column vector

参数
colcolumn index
返回
the column vector for index col

在文件 SGMatrix.h115 行定义.

SGVector< T > get_diagonal_vector ( ) const

Get a main diagonal vector. Matrix is not required to be square.

返回
main diagonal vector

在文件 SGMatrix.cpp1099 行定义.

T * get_row_sum ( T *  matrix,
int32_t  m,
int32_t  n 
)
static

Sums up all rows of a matrix and returns the resulting rowvector

在文件 SGMatrix.cpp320 行定义.

SGVector< T > get_row_vector ( index_t  row) const

Get a row vector

参数
rowrow index
返回
row vector

在文件 SGMatrix.cpp1088 行定义.

void init_data ( )
protectedvirtual

overridden to initialize empty data

实现了 SGReferencedData.

在文件 SGMatrix.cpp1035 行定义.

void inverse ( SGMatrix< float64_t matrix)
static

inverses square matrix in-place

Inverses square matrix in-place

在文件 SGMatrix.cpp885 行定义.

bool is_symmetric ( )

在文件 SGMatrix.cpp170 行定义.

bool is_symmetric ( )

在文件 SGMatrix.cpp187 行定义.

bool is_symmetric ( )

在文件 SGMatrix.cpp204 行定义.

bool is_symmetric ( )

Checks whether the matrix is symmetric or not. The equality check is performed using '==' operators for discrete types (int, char, bool) and using CMath::fequals method for floating types (float, double, long double, std::complex<double>) with default espilon values from std::numeric_limits

返回
whether the matrix is symmetric

在文件 SGMatrix.cpp154 行定义.

bool is_symmetric ( )

在文件 SGMatrix.cpp221 行定义.

void load ( CFile loader)

Load matrix from file

参数
loaderFile object via which to load data

在文件 SGMatrix.cpp1052 行定义.

void load ( CFile loader)

在文件 SGMatrix.cpp1067 行定义.

SGMatrix< float64_t > matrix_multiply ( SGMatrix< float64_t A,
SGMatrix< float64_t B,
bool  transpose_A = false,
bool  transpose_B = false,
float64_t  scale = 1.0 
)
static

Computes scale* A*B, where A and B may be transposed. Asserts for matching inner dimensions.

参数
Amatrix A
transpose_Aoptional whether A should be transposed before
Bmatrix B
transpose_Boptional whether B should be transposed before
scaleoptional scaling factor for result

在文件 SGMatrix.cpp947 行定义.

T max_single ( )
返回
the maximum single element of the matrix

在文件 SGMatrix.cpp240 行定义.

complex128_t max_single ( )

在文件 SGMatrix.cpp253 行定义.

operator EigenMatrixXtMap ( ) const

Wraps an Eigen3 matrix around the data of this matrix

在文件 SGMatrix.cpp93 行定义.

const T& operator() ( index_t  i_row,
index_t  i_col 
) const

Operator overload for matrix read only access

参数
i_row
i_col

在文件 SGMatrix.h138 行定义.

T& operator() ( index_t  i_row,
index_t  i_col 
)

Operator overload for matrix r/w access

参数
i_row
i_col

在文件 SGMatrix.h156 行定义.

bool operator== ( SGMatrix< T > &  other)

Check for pointer identity

在文件 SGMatrix.cpp106 行定义.

const T& operator[] ( index_t  index) const

Operator overload for matrix read only access

参数
indexto access

在文件 SGMatrix.h147 行定义.

T& operator[] ( index_t  index)

Operator overload for matrix r/w access

参数
indexto access

在文件 SGMatrix.h165 行定义.

float64_t * pinv ( float64_t matrix,
int32_t  rows,
int32_t  cols,
float64_t target = NULL 
)
static

Return the pseudo inverse for matrix when matrix has shape (rows, cols) the pseudo inverse has (cols, rows)

在文件 SGMatrix.cpp846 行定义.

int32_t ref ( )
protectedinherited

increase reference counter

返回
reference count

在文件 SGReferencedData.cpp64 行定义.

int32_t ref_count ( )
inherited

display reference counter

返回
reference count

在文件 SGReferencedData.cpp41 行定义.

void remove_column_mean ( )

Remove column mean

在文件 SGMatrix.cpp377 行定义.

void save ( CFile saver)

Save matrix to file

参数
saverFile object via which to save data

在文件 SGMatrix.cpp1073 行定义.

void save ( CFile saver)

在文件 SGMatrix.cpp1082 行定义.

void set_const ( const_elem)

Set matrix to a constant

在文件 SGMatrix.cpp133 行定义.

uint64_t size ( ) const

The size

在文件 SGMatrix.h187 行定义.

float64_t trace ( float64_t mat,
int32_t  cols,
int32_t  rows 
)
static

Compute trace

在文件 SGMatrix.cpp310 行定义.

void transpose_matrix ( T *&  matrix,
int32_t &  num_feat,
int32_t &  num_vec 
)
static

Transpose matrix

在文件 SGMatrix.cpp277 行定义.

int32_t unref ( )
protectedinherited

decrement reference counter and deallocate object if refcount is zero before or after decrementing it

返回
reference count

在文件 SGReferencedData.cpp84 行定义.

void zero ( )

在文件 SGMatrix.cpp147 行定义.

void zero ( )

fill matrix with zeros

在文件 SGMatrix.cpp140 行定义.

类成员变量说明

T* matrix

matrix

在文件 SGMatrix.h374 行定义.

index_t num_cols

number of columns of matrix

在文件 SGMatrix.h378 行定义.

index_t num_rows

number of rows of matrix

在文件 SGMatrix.h376 行定义.


The documentation for this singleton was generated from the following files:

SHOGUN 机器学习工具包 - 项目文档