Skip to content

Commit ef25f8c

Browse files
Alexey Stukalovalyst
authored andcommitted
fill_A_S_M!(): add !, specify argtypes
to match julia naming convention
1 parent 29f7f5b commit ef25f8c

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

src/additional_functions/parameters.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
function fill_A_S_M(A, S, M, A_indices, S_indices, M_indices, parameters)
1+
# fill A, S, and M matrices with the parameter values according to the parameters map
2+
function fill_A_S_M!(
3+
A::AbstractMatrix,
4+
S::AbstractMatrix,
5+
M::Union{AbstractVector, Nothing},
6+
A_indices::AbstractArrayParamsMap,
7+
S_indices::AbstractArrayParamsMap,
8+
M_indices::Union{AbstractArrayParamsMap, Nothing},
9+
parameters::AbstractVector,
10+
)
211
@inbounds for (iA, iS, par) in zip(A_indices, S_indices, parameters)
312
for index_A in iA
413
A[index_A] = par
@@ -88,12 +97,18 @@ function get_matrix_derivative(M_indices, parameters, n_long)
8897
return ∇M
8998
end
9099

91-
function fill_matrix(M, M_indices, parameters)
100+
# fill M with parameters
101+
function fill_matrix!(
102+
M::AbstractMatrix,
103+
M_indices::AbstractArrayParamsMap,
104+
parameters::AbstractVector,
105+
)
92106
for (iM, par) in zip(M_indices, parameters)
93107
for index_M in iM
94108
M[index_M] = par
95109
end
96110
end
111+
return M
97112
end
98113

99114
function get_partition(A_indices, S_indices)

src/imply/RAM/generic.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ gradient!(imply::RAM, par, model::AbstractSemSingle) =
222222

223223
# objective and gradient
224224
function objective!(imply::RAM, parameters, model, has_meanstructure::Val{T}) where {T}
225-
fill_A_S_M(
225+
fill_A_S_M!(
226226
imply.A,
227227
imply.S,
228228
imply.M,
@@ -250,7 +250,7 @@ function gradient!(
250250
model::AbstractSemSingle,
251251
has_meanstructure::Val{T},
252252
) where {T}
253-
fill_A_S_M(
253+
fill_A_S_M!(
254254
imply.A,
255255
imply.S,
256256
imply.M,
@@ -346,7 +346,7 @@ function check_acyclic(A_pre, n_par, A_indices)
346346
A_rand = copy(A_pre)
347347
randpar = rand(n_par)
348348

349-
fill_matrix(A_rand, A_indices, randpar)
349+
fill_matrix!(A_rand, A_indices, randpar)
350350

351351
# check if the model is acyclic
352352
acyclic = isone(det(I - A_rand))

src/imply/RAM/symbolic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function RAMSymbolic(;
112112
F[CartesianIndex.(1:n_var, ram_matrices.F_ind)] .= 1.0
113113

114114
set_RAMConstants!(A, S, M, ram_matrices.constants)
115-
fill_A_S_M(A, S, M, ram_matrices.A_ind, ram_matrices.S_ind, ram_matrices.M_ind, par)
115+
fill_A_S_M!(A, S, M, ram_matrices.A_ind, ram_matrices.S_ind, ram_matrices.M_ind, par)
116116

117117
A, S, F = sparse(A), sparse(S), sparse(F)
118118

0 commit comments

Comments
 (0)