Added static create helper methods to Vector.

This commit is contained in:
Relintai 2023-04-30 10:03:58 +02:00
parent fbfd546ee8
commit d39291c849
2 changed files with 32 additions and 0 deletions

View File

@ -927,6 +927,34 @@ Ref<MLPPVector> MLPPVector::vecn_full(int n, int k) const {
return vec;
}
Ref<MLPPVector> MLPPVector::create_vec_zero(int n) {
Ref<MLPPVector> vec;
vec.instance();
vec->resize(n);
vec->fill(0);
return vec;
}
Ref<MLPPVector> MLPPVector::create_vec_one(int n) {
Ref<MLPPVector> vec;
vec.instance();
vec->resize(n);
vec->fill(1);
return vec;
}
Ref<MLPPVector> MLPPVector::create_vec_full(int n, int k) {
Ref<MLPPVector> vec;
vec.instance();
vec->resize(n);
vec->fill(k);
return vec;
}
void MLPPVector::sin() {
real_t *out_ptr = ptrw();

View File

@ -181,6 +181,10 @@ public:
Ref<MLPPVector> vecn_one(int n) const;
Ref<MLPPVector> vecn_full(int n, int k) const;
static Ref<MLPPVector> create_vec_zero(int n);
static Ref<MLPPVector> create_vec_one(int n);
static Ref<MLPPVector> create_vec_full(int n, int k);
void sin();
Ref<MLPPVector> sinn() const;
void sinb(const Ref<MLPPVector> &a);