mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-12-21 14:56:47 +01:00
Added a static create helper for Matrix.
This commit is contained in:
parent
d39291c849
commit
9993bc9d4e
@ -1999,6 +1999,21 @@ Ref<MLPPMatrix> MLPPMatrix::identity_mat(int d) const {
|
||||
return identity_mat;
|
||||
}
|
||||
|
||||
Ref<MLPPMatrix> MLPPMatrix::create_identity_mat(int d) {
|
||||
Ref<MLPPMatrix> identity_mat;
|
||||
identity_mat.instance();
|
||||
identity_mat->resize(Size2i(d, d));
|
||||
identity_mat->fill(0);
|
||||
|
||||
real_t *im_ptr = identity_mat->ptrw();
|
||||
|
||||
for (int i = 0; i < d; i++) {
|
||||
im_ptr[identity_mat->calculate_index(i, i)] = 1;
|
||||
}
|
||||
|
||||
return identity_mat;
|
||||
}
|
||||
|
||||
Ref<MLPPMatrix> MLPPMatrix::cov() const {
|
||||
MLPPStat stat;
|
||||
|
||||
|
@ -248,6 +248,8 @@ public:
|
||||
Ref<MLPPMatrix> identityn() const;
|
||||
Ref<MLPPMatrix> identity_mat(int d) const;
|
||||
|
||||
static Ref<MLPPMatrix> create_identity_mat(int d);
|
||||
|
||||
Ref<MLPPMatrix> cov() const;
|
||||
void covo(Ref<MLPPMatrix> out) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user