40 for (
size_t r = 0; r <
rows; ++r)
42 for (
size_t c = 0; c <
cols; ++c)
44 double val =
At(r, c);
65 _(
"Negative standard deviation"));
69 int hwin = (int)ceil(
Thrice(sigma));
70 int size = hwin + hwin + 1;
73 for (
int tmp = 0; tmp < size; ++tmp)
74 mat.
At(0, tmp) =
MeanGauss(
double(tmp) -
double(hwin), sigma);
92 _(
"Negative standard deviation"));
101 int hwin = (int)ceil(
Thrice(sigma));
102 int size = hwin + hwin + 1;
105 for (
int tmp = 0; tmp < size; ++tmp)
107 double v = (double)hwin - (
double)tmp;
108 mat.
At(0, tmp) = (v *
Gauss(v, sigma) +
109 (v - 0.5) *
Gauss(v - 0.5, sigma) +
110 (v + 0.5) *
Gauss(v + 0.5, sigma)) / 3.0;
129 _(
"Negative standard deviation"));
136 int hwin = (int)ceil(6 * sigma);
137 int size = hwin + hwin + 1;
139 for (
int tmp = 0; tmp < size; ++tmp)
141 double v = (double)tmp - (
double)hwin;
143 (
Sqr(v - 0.5) -
Sqr(sigma)) *
Gauss(v - 0.5, sigma) +
144 (
Sqr(v + 0.5) -
Sqr(sigma)) *
Gauss(v + 0.5, sigma)) / 3.0;
164 for (
size_t r = 0; r < s; ++r)
166 double vr =
At(r, 0);
168 for (
size_t c = 0; c < s; ++c)
170 m.
At(r, c) = vr *
At(c, 0);
193 if (el.
GetName() != getClassName())
196 _(
"Wrong XML element."));
204 auto vals = Data::ASCII85Decode<double>(t.GetValue());
205 if (vals.size() != nc * nr)
207 _(
"Cannot convert CDATA."));
228 el.SetAttribute(
"nb_columns",
int(
cols));
231 xml::Text t(el.PushBackText(text,
false));
238 Cloner::Register<MatrixDouble>();
static MatrixDouble NewGaussianLineDerivative(double sigma)
Creates a line matrix with the derivative of a centered Gaussian.
size_t GetRows() const noexcept
Returns the number of rows.
size_t GetCols() const noexcept
Returns the number of columns.
StringUTF8 GetName() const
Gets the label of the element.
double CumulateSquaredCells() const
Computes the sum of the squared elements.
double MeanGauss(double x, double sigma)
Computes Gauss function at x for a given standard deviation (centered in 0) – to use with matrices...
MatrixDouble(const Matrix< double > &m)
static MatrixDouble NewGaussianLineSecondDerivative(double sigma)
Creates a line matrix with the second derivative of a centered Gaussian.
static MatrixDouble NewGaussianLine(double sigma)
Creates a line matrix with a centered Gaussian.
#define CRN_END_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
virtual xml::Element Serialize(xml::Element &parent) const
#define CRN_DATA_FACTORY_REGISTER(elemname, classname)
Registers a class to the data factory.
constexpr SumType< T > Sqr(const T &v) noexcept(noexcept(v *v))
Returns the square of a value.
virtual void Deserialize(xml::Element &el)
void SetAttribute(const StringUTF8 &name, const StringUTF8 &value)
Sets the value of an attribute.
double Gauss(double x, double sigma)
Computes Gauss function at x for a given standard deviation (centered in 0)
T GetAttribute(const StringUTF8 &name, bool silent=true) const
Gets an attribute.
Node GetFirstChild()
Gets the first child node.
const double & At(size_t pos) const noexcept
Square double matrix class.
constexpr TypeInfo< T >::SumType Thrice(const T &v) noexcept(noexcept(v+v))
Returns three times a value.
A character string class.
crn::StringUTF8 ASCII85Encode(const uint8_t *const data, size_t len)
Encodes any data into a printable string.
Element PushBackElement(const StringUTF8 &name)
Adds an element at the end of the children list.
Invalid argument error (e.g.: nullptr pointer)
SquareMatrixDouble MakeVectorRightAutoProduct() const
Get the product of a column vector by its own transposed on the right side.
#define CRN_BEGIN_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.