fastText: /data/users/cpuhrsch/fbsource/fbcode/deeplearning/fastText/src/matrix.h Source File

| fastText d00d36476b15 Fast text processing tool/library

matrix.h
Go to the documentation of this file.
1
10 #ifndef FASTTEXT_MATRIX_H
11 #define FASTTEXT_MATRIX_H
12
13 #include <cstdint>
14 #include <istream>
15 #include <ostream>
16
17 #include "real.h"
18
19 namespace fasttext {
20
21 class Vector;
22
23 class Matrix {
24
25 public:
26 real* data_;
27 int64_t m_;
28 int64_t n_;
29
30 Matrix();
31 Matrix(int64_t, int64_t);
32 Matrix(const Matrix&);
33 Matrix& operator=(const Matrix&);
34 ~Matrix();
35
36 inline const real& at(int64_t i, int64_t j) const {return data_[i * n_ + j];};
37 inline real& at(int64_t i, int64_t j) {return data_[i * n_ + j];};
38
39
40 void zero();
41 void uniform(real);
42 real dotRow(const Vector&, int64_t) const;
43 void addRow(const Vector&, int64_t, real);
44
45 void multiplyRow(const Vector& nums, int64_t ib = 0, int64_t ie = -1);
46 void divideRow(const Vector& denoms, int64_t ib = 0, int64_t ie = -1);
47
48 real l2NormRow(int64_t i) const;
49 void l2NormRow(Vector& norms) const;
50
51 void save(std::ostream&);
52 void load(std::istream&);
53 };
54
55 }
56
57 #endif
fasttext::Matrix::dotRow
real dotRow(const Vector &, int64_t) const
Definition: matrix.cc:68
fasttext::Matrix::at
const real & at(int64_t i, int64_t j) const
Definition: matrix.h:36
fasttext::Matrix::m_
int64_t m_
Definition: matrix.h:27
fasttext::Matrix::at
real & at(int64_t i, int64_t j)
Definition: matrix.h:37
fasttext
Definition: args.cc:17
fasttext::Vector
Definition: vector.h:23
fasttext::Matrix::l2NormRow
real l2NormRow(int64_t i) const
Definition: matrix.cc:114
real.h
fasttext::Matrix::~Matrix
~Matrix()
Definition: matrix.cc:50
fasttext::Matrix::n_
int64_t n_
Definition: matrix.h:28
fasttext::Matrix::zero
void zero()
Definition: matrix.cc:54
fasttext::Matrix::save
void save(std::ostream &)
Definition: matrix.cc:130
fasttext::Matrix::divideRow
void divideRow(const Vector &denoms, int64_t ib=0, int64_t ie=-1)
Definition: matrix.cc:101
fasttext::Matrix::load
void load(std::istream &)
Definition: matrix.cc:136
fasttext::Matrix::operator=
Matrix & operator=(const Matrix &)
Definition: matrix.cc:42
fasttext::Matrix::multiplyRow
void multiplyRow(const Vector &nums, int64_t ib=0, int64_t ie=-1)
Definition: matrix.cc:88
fasttext::Matrix::addRow
void addRow(const Vector &, int64_t, real)
Definition: matrix.cc:79
fasttext::real
float real
Definition: real.h:15
fasttext::Matrix
Definition: matrix.h:23
fasttext::Matrix::uniform
void uniform(real)
Definition: matrix.cc:60
fasttext::Matrix::data_
real * data_
Definition: matrix.h:26
fasttext::Matrix::Matrix
Matrix()
Definition: matrix.cc:21