36#ifndef STK_HOUSEHOLDER_H
37#define STK_HOUSEHOLDER_H
55template <
class Vector>
59 Real scale = x.normInf(),
v1, norm2 = 0.0;
62 norm2 = (x.asDerived().sub(
_R(x.begin()+1,x.lastIdx()))/=scale).norm2();
66 {
v1 = x.front(); x.front() = 0.0; }
73 x.front() = (s =
aux1-norm2)/norm2;
75 x.asDerived().sub(
_R(x.begin()+1,x.lastIdx())) /= s;
89template<
class Lhs,
class Rhs>
94 for (
int i=
v.begin()+1;
i<
v.end();
i++)
sum += x[
i] *
v[
i];
108template <
class Lhs,
class Rhs>
113 Real beta =
v.front();
117 for (
int j=M.beginCols();
j<M.endCols();
j++)
120 ColVector
Mj(M.asDerived(),
v.range(),
j);
125 for(
int i =
v.begin()+1;
i <
v.end(); ++
i)
Mj[
i] +=
v[
i] *
aux;
141template <
class Lhs,
class Rhs>
146 int first =
H.beginCols(),
last = std::min(
H.lastIdxCols(),
H.lastIdxRows());
150 for (
int j=
last;
j>=first;
j--)
169template <
class Lhs,
class Rhs>
173 Real beta =
v.front();
177 for (
int i=M.beginRows();
i<M.endRows();
i++)
201template <
class TContainer2D,
class Rhs>
205 int first =
H.beginCols(),
last = std::min(
H.lastIdxCols(),
H.lastIdxRows());
209 for (
int j=
last;
j>=first;
j--)
In this file we define the base class for Arrays.
#define _R(first, last)
Utility macro that can be used in a similar way that first:last.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
Real dotHouse(ExprBase< Lhs > const &x, ExprBase< Rhs > const &v)
dot product with a Householder vector.
void applyLeftHouseholderVector(ArrayBase< Lhs > const &M, ExprBase< Rhs > const &v)
left multiplication by a Householder vector.
void applyRightHouseholderVector(ArrayBase< Lhs > const &M, ExprBase< Rhs > const &v)
right multiplication by a Householder vector.
void applyLeftHouseholderArray(ArrayBase< Lhs > const &M, ArrayBase< Rhs > const &H)
left multiplication by a Householder array.
void applyRightHouseholderArray(ArrayBase< TContainer2D > const &M, ArrayBase< Rhs > const &H)
left multiplication by a Householder ArrayXX.
Real house(ArrayBase< Vector > &x)
Compute the Householder vector v of a vector x.
Arrays::SumOp< Lhs, Rhs >::result_type sum(Lhs const &lhs, Rhs const &rhs)
convenience function for summing two arrays
Type sign(Type const &x, Type const &y=Type(1))
template sign value sign(x) * y: Type should be an integral type
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.