Dynare++: further simplification in Vector class
parent
af722f438f
commit
099a1de607
|
@ -6,16 +6,12 @@
|
||||||
|
|
||||||
#include <dynblas.h>
|
#include <dynblas.h>
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
ZeroPad zero_pad;
|
|
||||||
|
|
||||||
Vector::Vector(const Vector &v)
|
Vector::Vector(const Vector &v)
|
||||||
: len(v.len), data{new double[len], [](double *arr) { delete[] arr; }}
|
: len(v.len), data{new double[len], [](double *arr) { delete[] arr; }}
|
||||||
{
|
{
|
||||||
|
@ -156,20 +152,11 @@ void
|
||||||
Vector::zeros()
|
Vector::zeros()
|
||||||
{
|
{
|
||||||
if (s == 1)
|
if (s == 1)
|
||||||
{
|
std::fill_n(base(), len, 0.0);
|
||||||
double *p = base();
|
|
||||||
for (int i = 0; i < len/ZeroPad::length;
|
|
||||||
i++, p += ZeroPad::length)
|
|
||||||
memcpy(p, zero_pad.getBase(), sizeof(double)*ZeroPad::length);
|
|
||||||
for (; p < base()+len; p++)
|
|
||||||
*p = 0.0;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
operator[](i) = 0.0;
|
operator[](i) = 0.0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Vector::nans()
|
Vector::nans()
|
||||||
|
@ -410,8 +397,3 @@ ConstVector::print() const
|
||||||
std::cout << i << '\t' << std::setw(8) << operator[](i) << std::endl;
|
std::cout << i << '\t' << std::setw(8) << operator[](i) << std::endl;
|
||||||
std::cout.flags(ff);
|
std::cout.flags(ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroPad::ZeroPad()
|
|
||||||
{
|
|
||||||
pad.fill(0.0);
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* to avoid running virtual method invokation mechanism. Some
|
* to avoid running virtual method invokation mechanism. Some
|
||||||
* members, and methods are thus duplicated */
|
* members, and methods are thus duplicated */
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <complex>
|
#include <complex>
|
||||||
|
|
||||||
|
@ -216,19 +215,4 @@ public:
|
||||||
void print() const;
|
void print() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ZeroPad
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const int length = 16;
|
|
||||||
private:
|
|
||||||
std::array<double, length> pad;
|
|
||||||
public:
|
|
||||||
ZeroPad();
|
|
||||||
const double *
|
|
||||||
getBase() const
|
|
||||||
{
|
|
||||||
return pad.data();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* VECTOR_H */
|
#endif /* VECTOR_H */
|
||||||
|
|
Loading…
Reference in New Issue