13 #ifndef __SGMATRIX_H__ 14 #define __SGMATRIX_H__ 17 #include <shogun/lib/config.h> 26 template <
class,
int,
int,
int,
int,
int>
class Matrix;
28 template <
class,
int,
class>
class Map;
33 template<
class T>
class SGVector;
84 #ifndef SWIG // SWIG should skip this part 85 #if defined(HAVE_CXX0X) || defined(HAVE_CXX11) 88 template <
typename ST>
using container_type =
SGMatrix<ST>;
90 #endif // define (HAVE_CXX0X) || defined(HAVE_CXX11) 135 #ifndef SWIG // SWIG should skip this part 143 const int64_t c = col;
167 const int64_t c = i_col;
187 const int64_t c = i_col;
200 #endif // SWIG should skip this part 210 return (*
this)(row, col);
221 (*this)(row, col)=el;
224 #ifndef SWIG // SWIG should skip this part 306 T*&
matrix, int32_t& num_feat, int32_t& num_vec);
350 int n,
int il,
int iu);
362 bool transpose_A=
false,
bool transpose_B=
false,
379 float64_t* mat, int32_t cols, int32_t rows);
401 const T*
matrix, int32_t rows, int32_t cols,
402 const char* name=
"matrix",
const char* prefix=
"");
407 const char* prefix=
"");
434 #endif // #ifndef SWIG // SWIG should skip this part 448 std::atomic<bool> m_on_gpu;
453 void assert_on_cpu()
const 456 SG_SERROR(
"Direct memory access not possible when data is in GPU memory.\n");
470 #endif // __SGMATRIX_H__ T & operator[](index_t index)
static 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)
const T & operator[](index_t index) const
SGMatrix< T > & operator=(const SGMatrix< T > &)
const T & operator()(index_t i_row, index_t i_col) const
const T & get_element(index_t row, index_t col)
Eigen::Map< EigenMatrixXt, 0, Eigen::Stride< 0, 0 > > EigenMatrixXtMap
static T * get_row_sum(T *matrix, int32_t m, int32_t n)
bool is_symmetric() const
static void transpose_matrix(T *&matrix, int32_t &num_feat, int32_t &num_vec)
void scale(SGVector< T > &a, SGVector< T > &result, T alpha=1)
void set_element(const T &el, index_t row, index_t col)
Eigen::Matrix< T,-1,-1, 0,-1,-1 > EigenMatrixXt
static float64_t * pinv(float64_t *matrix, int32_t rows, int32_t cols, float64_t *target=NULL)
static T * get_column_sum(T *matrix, int32_t m, int32_t n)
void display_matrix(const char *name="matrix") const
SG_FORCED_INLINE bool operator==(const SGMatrix< T > &other) const
SGVector< T > get_diagonal_vector() const
SGMatrix< T > clone() const
T * get_column_vector(index_t col) const
static SGVector< float64_t > compute_eigenvectors(SGMatrix< float64_t > matrix)
std::shared_ptr< GPUMemoryBase< T > > gpu_ptr
static T * clone_matrix(const T *matrix, int32_t nrows, int32_t ncols)
shogun reference count managed data
static SGMatrix< T > create_identity_matrix(index_t size, T scale)
A File access base class.
SGVector< T > get_row_vector(index_t row) const
static void create_diagonal_matrix(T *matrix, T *v, int32_t size)
void remove_column_mean()
static float64_t trace(float64_t *mat, int32_t cols, int32_t rows)
static void inverse(SGMatrix< float64_t > matrix)
inverses square matrix in-place
void compute_few_eigenvectors(double *matrix_, double *&eigenvalues, double *&eigenvectors, int n, int il, int iu)
all of classes and functions are contained in the shogun namespace
Interface for GPU memory libraries.
Linalg methods with Eigen3 backend.
T & operator()(index_t i_row, index_t i_col)
void set_const(T const_elem)
bool equals(const SGMatrix< T > &other) const
static SGMatrix< T > get_allocated_matrix(index_t num_rows, index_t num_cols, SGMatrix< T > pre_allocated=SGMatrix< T >())
virtual void copy_data(const SGReferencedData &orig)
static void center_matrix(T *matrix, int32_t m, int32_t n)