vendor/fastText/src/densematrix.h in fasttext-0.1.2 vs vendor/fastText/src/densematrix.h in fasttext-0.1.3
- old
+ new
@@ -6,30 +6,33 @@
* LICENSE file in the root directory of this source tree.
*/
#pragma once
+#include <assert.h>
#include <cstdint>
#include <istream>
#include <ostream>
+#include <stdexcept>
#include <vector>
-#include <assert.h>
#include "matrix.h"
#include "real.h"
namespace fasttext {
class Vector;
class DenseMatrix : public Matrix {
protected:
std::vector<real> data_;
+ void uniformThread(real, int, int32_t);
public:
DenseMatrix();
explicit DenseMatrix(int64_t, int64_t);
+ explicit DenseMatrix(int64_t m, int64_t n, real* dataPtr);
DenseMatrix(const DenseMatrix&) = default;
DenseMatrix(DenseMatrix&&) noexcept;
DenseMatrix& operator=(const DenseMatrix&) = delete;
DenseMatrix& operator=(DenseMatrix&&) = delete;
virtual ~DenseMatrix() noexcept override = default;
@@ -54,11 +57,11 @@
}
inline int64_t cols() const {
return n_;
}
void zero();
- void uniform(real);
+ void uniform(real, unsigned int, int32_t);
void multiplyRow(const Vector& nums, int64_t ib = 0, int64_t ie = -1);
void divideRow(const Vector& denoms, int64_t ib = 0, int64_t ie = -1);
real l2NormRow(int64_t i) const;
@@ -69,7 +72,12 @@
void addRowToVector(Vector& x, int32_t i) const override;
void addRowToVector(Vector& x, int32_t i, real a) const override;
void save(std::ostream&) const override;
void load(std::istream&) override;
void dump(std::ostream&) const override;
+
+ class EncounteredNaNError : public std::runtime_error {
+ public:
+ EncounteredNaNError() : std::runtime_error("Encountered NaN.") {}
+ };
};
} // namespace fasttext