Skip to content

Commit

Permalink
Merge pull request #798 from stan-dev/symmetrize_from_lower_tri
Browse files Browse the repository at this point in the history
Add symmetrize_from_lower_tri
  • Loading branch information
rok-cesnovar authored Jan 18, 2021
2 parents 16f0330 + a131c80 commit f22db2d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/middle/Stan_math_signatures.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,7 @@ let () =
add_unqualified ("sum", ReturnType UReal, [UMatrix]) ;
add_unqualified ("svd_U", ReturnType UMatrix, [UMatrix]) ;
add_unqualified ("svd_V", ReturnType UMatrix, [UMatrix]) ;
add_unqualified ("symmetrize_from_lower_tri", ReturnType UMatrix, [UMatrix]) ;
add_unqualified ("tail", ReturnType URowVector, [URowVector; UInt]) ;
add_unqualified ("tail", ReturnType UVector, [UVector; UInt]) ;
List.iter
Expand Down
7 changes: 6 additions & 1 deletion test/integration/good/code-gen/cpp.expected
Original file line number Diff line number Diff line change
Expand Up @@ -20209,7 +20209,8 @@ using stan::model::nil_index_list;
using namespace stan::math;
using stan::math::pow;

static int current_statement__ = 0;
stan::math::profile_map profiles__;
static int current_statement__= 0;
static const std::vector<string> locations_array__ = {" (found before start of program)",
" (in 'param-constraint.stan', line 7, column 2 to column 38)",
" (in 'param-constraint.stan', line 8, column 2 to column 38)",
Expand Down Expand Up @@ -20713,6 +20714,10 @@ stan::model::model_base& new_model(
return *m;
}

stan::math::profile_map& get_stan_profile_data() {
return param_constraint_model_namespace::profiles__;
}

#endif


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19465,6 +19465,28 @@ transformed parameters {
transformed_param_matrix = svd_V(d_matrix);
transformed_param_matrix = svd_V(p_matrix);
}
model {
y_p ~ normal(0, 1);
}

$ ../../../../../../../install/default/bin/stanc --auto-format symmetrize_from_lower_tri.stan
data {
int d_int;
matrix[d_int, d_int] d_matrix;
}
transformed data {
matrix[d_int, d_int] transformed_data_matrix;
transformed_data_matrix = symmetrize_from_lower_tri(d_matrix);
}
parameters {
real y_p;
matrix[d_int, d_int] p_matrix;
}
transformed parameters {
matrix[d_int, d_int] transformed_param_matrix;
transformed_param_matrix = symmetrize_from_lower_tri(d_matrix);
transformed_param_matrix = symmetrize_from_lower_tri(p_matrix);
}
model {
y_p ~ normal(0, 1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
data {
int d_int;
matrix[d_int,d_int] d_matrix;
}

transformed data {
matrix[d_int,d_int] transformed_data_matrix;

transformed_data_matrix = symmetrize_from_lower_tri(d_matrix);
}
parameters {
real y_p;
matrix[d_int,d_int] p_matrix;
}
transformed parameters {
matrix[d_int,d_int] transformed_param_matrix;

transformed_param_matrix = symmetrize_from_lower_tri(d_matrix);
transformed_param_matrix = symmetrize_from_lower_tri(p_matrix);
}
model {
y_p ~ normal(0,1);
}
1 change: 1 addition & 0 deletions test/integration/signatures/stan_math_sigs.expected
Original file line number Diff line number Diff line change
Expand Up @@ -23503,6 +23503,7 @@ real sum(matrix)
real sum(real[])
matrix svd_U(matrix)
matrix svd_V(matrix)
matrix symmetrize_from_lower_tri(matrix)
vector tail(vector, int)
row_vector tail(row_vector, int)
int[] tail(int[], int)
Expand Down

0 comments on commit f22db2d

Please sign in to comment.