Stan Math Library: stan/math/prim/mat/fun/multiply_lower_tri_self_transpose.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

multiply_lower_tri_self_transpose.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_MULTIPLY_LOWER_TRI_SELF_TRANSPOSE_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_MULTIPLY_LOWER_TRI_SELF_TRANSPOSE_HPP
3
4 #include <stan/math/prim/mat/fun/typedefs.hpp>
5
6 namespace stan {
7 namespace math {
8
17 inline matrix_d
18 multiply_lower_tri_self_transpose(const matrix_d& L) {
19 int K = L.rows();
20 int J = L.cols();
21 int k;
22 matrix_d LLt(K, K);
23 matrix_d Lt = L.transpose();
24
25 if (K == 0)
26 return matrix_d(0, 0);
27 if (K == 1) {
28 matrix_d result(1, 1);
29 result(0, 0) = L(0, 0) * L(0, 0);
30 return result;
31 }
32
33 for (int m = 0; m < K; ++m) {
34 k = (J < m + 1) ? J : m + 1;
35 LLt(m, m) = Lt.col(m).head(k).squaredNorm();
36 for (int n = (m + 1); n < K; ++n) {
37 LLt(n, m) = LLt(m, n) = Lt.col(m).head(k).dot(Lt.col(n).head(k));
38 }
39 }
40 return LLt;
41 }
42
43 }
44 }
45 #endif
stan
Definition: log_sum_exp.hpp:8
stan::math::multiply_lower_tri_self_transpose
Eigen::Matrix< fvar< T >, R, R > multiply_lower_tri_self_transpose(const Eigen::Matrix< fvar< T >, R, C > &m)
Definition: multiply_lower_tri_self_transpose.hpp:17
stan::math::matrix_d
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
Definition: typedefs.hpp:23
typedefs.hpp

[ Stan Home Page ] © 2011–2016, Stan Development Team.