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:
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
real dotRow(const Vector &, int64_t) const
Definition: matrix.cc:68
const real & at(int64_t i, int64_t j) const
Definition: matrix.h:36
int64_t m_
Definition: matrix.h:27
real & at(int64_t i, int64_t j)
Definition: matrix.h:37
Definition: args.cc:17
Definition: vector.h:23
real l2NormRow(int64_t i) const
Definition: matrix.cc:114
~Matrix()
Definition: matrix.cc:50
int64_t n_
Definition: matrix.h:28
void zero()
Definition: matrix.cc:54
void save(std::ostream &)
Definition: matrix.cc:130
void divideRow(const Vector &denoms, int64_t ib=0, int64_t ie=-1)
Definition: matrix.cc:101
void load(std::istream &)
Definition: matrix.cc:136
Matrix & operator=(const Matrix &)
Definition: matrix.cc:42
void multiplyRow(const Vector &nums, int64_t ib=0, int64_t ie=-1)
Definition: matrix.cc:88
void addRow(const Vector &, int64_t, real)
Definition: matrix.cc:79
float real
Definition: real.h:15
Definition: matrix.h:23
void uniform(real)
Definition: matrix.cc:60
real * data_
Definition: matrix.h:26
Matrix()
Definition: matrix.cc:21