MLPPMatrix math api rework pt4.

This commit is contained in:
Relintai 2023-04-24 21:50:03 +02:00
parent de8c7b2868
commit 991fb93ece
2 changed files with 36 additions and 7 deletions

View File

@ -609,24 +609,50 @@ void MLPPMatrix::scalar_addb(const real_t scalar, const Ref<MLPPMatrix> &A) {
}
}
Ref<MLPPMatrix> MLPPMatrix::lognm(const Ref<MLPPMatrix> &A) {
ERR_FAIL_COND_V(!A.is_valid(), Ref<MLPPVector>());
void MLPPMatrix::log() {
int ds = data_size();
real_t *out_ptr = ptrw();
for (int i = 0; i < ds; ++i) {
out_ptr[i] = Math::log(out_ptr[i]);
}
}
Ref<MLPPMatrix> MLPPMatrix::logn() {
Ref<MLPPMatrix> out;
out.instance();
out->resize(size());
int data_size = A->data_size();
out->resize(A->size());
int ds = data_size();
const real_t *a_ptr = A->ptr();
const real_t *a_ptr = ptr();
real_t *out_ptr = out->ptrw();
for (int i = 0; i < data_size; ++i) {
for (int i = 0; i < ds; ++i) {
out_ptr[i] = Math::log(a_ptr[i]);
}
return out;
}
void MLPPMatrix::logb(const Ref<MLPPMatrix> &A) {
ERR_FAIL_COND(!A.is_valid());
Size2i a_size = A->size();
if (a_size != size()) {
resize(a_size);
}
int ds = data_size();
const real_t *a_ptr = A->ptr();
real_t *out_ptr = ptrw();
for (int i = 0; i < ds; ++i) {
out_ptr[i] = Math::log(a_ptr[i]);
}
}
Ref<MLPPMatrix> MLPPMatrix::log10nm(const Ref<MLPPMatrix> &A) {
ERR_FAIL_COND_V(!A.is_valid(), Ref<MLPPVector>());

View File

@ -625,7 +625,10 @@ public:
Ref<MLPPMatrix> scalar_addn(const real_t scalar) const;
void scalar_addb(const real_t scalar, const Ref<MLPPMatrix> &A);
Ref<MLPPMatrix> lognm(const Ref<MLPPMatrix> &A);
void log();
Ref<MLPPMatrix> logn();
void logb(const Ref<MLPPMatrix> &A);
Ref<MLPPMatrix> log10nm(const Ref<MLPPMatrix> &A);
Ref<MLPPMatrix> expnm(const Ref<MLPPMatrix> &A);
Ref<MLPPMatrix> erfnm(const Ref<MLPPMatrix> &A);