Added a new helper method to MLPPMatrix.

This commit is contained in:
Relintai 2023-10-25 00:53:41 +02:00
parent ecf5e300de
commit dfee510778
2 changed files with 26 additions and 0 deletions

View File

@ -558,6 +558,18 @@ void MLPPMatrix::set_from_arrays(const Array &p_from) {
}
}
void MLPPMatrix::set_from_ptr(const real_t *p_from, const int p_size_y, const int p_size_x) {
_data = NULL;
ERR_FAIL_COND(!p_from);
resize(Size2i(p_size_x, p_size_y));
int ds = data_size();
for (int i = 0; i < ds; ++i) {
_data[i] = p_from[i];
}
}
/*
std::vector<std::vector<real_t>> MLPPMatrix::gramMatrix(std::vector<std::vector<real_t>> A) {
return matmult(transpose(A), A); // AtA
@ -3005,6 +3017,18 @@ MLPPMatrix::MLPPMatrix(const Array &p_from) {
set_from_arrays(p_from);
}
MLPPMatrix::MLPPMatrix(const real_t *p_from, const int p_size_y, const int p_size_x) {
_data = NULL;
ERR_FAIL_COND(!p_from);
resize(Size2i(p_size_x, p_size_y));
int ds = data_size();
for (int i = 0; i < ds; ++i) {
_data[i] = p_from[i];
}
}
MLPPMatrix::~MLPPMatrix() {
if (_data) {
reset();

View File

@ -136,6 +136,7 @@ public:
void set_from_mlpp_vectors_array(const Array &p_from);
void set_from_vectors(const Vector<Vector<real_t>> &p_from);
void set_from_arrays(const Array &p_from);
void set_from_ptr(const real_t *p_from, const int p_size_y, const int p_size_x);
//std::vector<std::vector<real_t>> gramMatrix(std::vector<std::vector<real_t>> A);
//bool linearIndependenceChecker(std::vector<std::vector<real_t>> A);
@ -359,6 +360,7 @@ public:
MLPPMatrix(const MLPPMatrix &p_from);
MLPPMatrix(const Vector<Vector<real_t>> &p_from);
MLPPMatrix(const Array &p_from);
MLPPMatrix(const real_t *p_from, const int p_size_y, const int p_size_x);
~MLPPMatrix();