34 #ifndef SHARK_LINALG_ROTATIONS_H 35 #define SHARK_LINALG_ROTATIONS_H 39 namespace shark{
namespace blas{
51 template<
class X,
class R>
53 vector_expression<X, cpu_tag>
const& x,
54 vector_expression<R, cpu_tag>& reflection
67 typedef typename X::value_type Value;
69 double norm = norm_2(x);
73 noalias(reflection()) = x;
74 reflection()(0) -= norm;
75 reflection() /= (x()(0) - norm);
78 Value
beta = (norm - x()(0)) / norm;
84 template<
class Mat,
class R,
class T,
class Device>
86 matrix_expression<Mat, Device> & matrix,
87 vector_expression<R, Device>
const& reflection,
90 SIZE_CHECK(matrix().size2() == reflection().size());
94 if(reflection().size() == 1){
99 SIZE_CHECK(matrix().size2() == reflection().size());
101 blas::vector<T> temp = prod(matrix,reflection);
104 noalias(matrix()) -= beta * outer_prod(temp,reflection);
111 template<
class Mat,
class R,
class T,
class Device>
113 matrix_expression<Mat, Device> & matrix,
114 vector_expression<R, Device>
const& reflection,
118 SIZE_CHECK(matrix().size1() == reflection().size());
122 if(reflection().size() == 1){
127 blas::vector<T> temp = prod(trans(matrix),reflection);
130 noalias(matrix()) -= beta * outer_prod(reflection,temp);
136 template<
class Mat,
class R,
class T,
class Device>
138 temporary_proxy<Mat> matrix,
139 vector_expression<R, Device>
const& reflection,
167 template<
class MatrixT>
169 MatrixT& matrix = matrixC();
172 size_t size = matrix.size1();
173 diag(matrix) = repeat(1.0,size);
177 for(std::size_t i = 2; i != size+1;++i){
179 for(std::size_t j=0;j != i; ++j){
182 subrange(v,0,i) /=norm_2(subrange(v,0,i));
185 v(0) += v0/std::abs(v0);
189 double normvSqr = norm_sqr(subrange(v,0,i));
199 RealMatrix mat(size,size);