Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Willi Mutschler
dynare
Commits
c6a09a65
Verified
Commit
c6a09a65
authored
5 years ago
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
kronecker MEX: improve comments using UTF-8
parent
7347554d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mex/sources/kronecker/A_times_B_kronecker_C.cc
+3
-3
3 additions, 3 deletions
mex/sources/kronecker/A_times_B_kronecker_C.cc
mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc
+11
-11
11 additions, 11 deletions
mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc
with
14 additions
and
14 deletions
mex/sources/kronecker/A_times_B_kronecker_C.cc
+
3
−
3
View file @
c6a09a65
...
...
@@ -18,7 +18,7 @@
*/
/*
* This mex file computes A
*kron
(B
,
C) or A
*kron
(B
,
B) without explicit
e
ly building
kron(B,C) or kron(B,B)
, so that
* This mex file computes A
·
(B
⊗
C) or A
·
(B
⊗
B) without explicitly building
B⊗C or B⊗B
, so that
* one can consider large matrices B and/or C.
*/
...
...
@@ -127,14 +127,14 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
size_t
mB
=
mxGetM
(
prhs
[
1
]);
size_t
nB
=
mxGetN
(
prhs
[
1
]);
size_t
mC
,
nC
;
if
(
nrhs
==
4
)
// A
*kron
(B
,
C) is to be computed.
if
(
nrhs
==
4
)
// A
·
(B
⊗
C) is to be computed.
{
mC
=
mxGetM
(
prhs
[
2
]);
nC
=
mxGetN
(
prhs
[
2
]);
if
(
mB
*
mC
!=
nA
)
DYN_MEX_FUNC_ERR_MSG_TXT
(
"Input dimension error!"
);
}
else
// A
*kron
(B
,
B) is to be computed.
else
// A
·
(B
⊗
B) is to be computed.
{
if
(
mB
*
mB
!=
nA
)
DYN_MEX_FUNC_ERR_MSG_TXT
(
"Input dimension error!"
);
...
...
This diff is collapsed.
Click to expand it.
mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc
+
11
−
11
View file @
c6a09a65
...
...
@@ -18,9 +18,9 @@
*/
/*
* This mex file computes A
*kron
(B
,
C) or A
*kron
(B
,
B) without explicitly building
kron(B,C) or kron(B,B)
, so that
* one can consider large matrices A, B and/or C, and assuming that A is a the hessian of a
dsge
model
* (dynare format). This mex file should not be used outside dr
1
.m.
* This mex file computes A
·
(B
⊗
C) or A
·
(B
⊗
B) without explicitly building
B⊗C or B⊗B
, so that
* one can consider large matrices A, B and/or C, and assuming that A is a the hessian of a
DSGE
model
* (dynare format). This mex file should not be used outside d
yn_second_order_solve
r.m.
*/
#include
<algorithm>
...
...
@@ -38,7 +38,7 @@ sparse_hessian_times_B_kronecker_B(const mwIndex *isparseA, const mwIndex *jspar
const
double
*
B
,
double
*
D
,
size_t
mA
,
size_t
nA
,
size_t
mB
,
size_t
nB
,
int
number_of_threads
)
{
/*
** Loop over the columns of
kron(B,B)
(or of the result matrix D).
** Loop over the columns of
B⊗B
(or of the result matrix D).
** This loop is splitted into two nested loops because we use the
** symmetric pattern of the hessian matrix.
*/
...
...
@@ -52,13 +52,13 @@ sparse_hessian_times_B_kronecker_B(const mwIndex *isparseA, const mwIndex *jspar
#endif
for
(
mwIndex
j2B
=
j1B
;
j2B
<
static_cast
<
mwIndex
>
(
nB
);
j2B
++
)
{
mwIndex
jj
=
j1B
*
nB
+
j2B
;
// column of
kron(B,B)
index.
mwIndex
jj
=
j1B
*
nB
+
j2B
;
// column of
B⊗B
index.
mwIndex
iv
=
0
;
int
nz_in_column_ii_of_A
=
0
;
mwIndex
k1
=
0
;
mwIndex
k2
=
0
;
/*
** Loop over the rows of
kron(B,B)
(column jj).
** Loop over the rows of
B⊗B
(column jj).
*/
for
(
mwIndex
ii
=
0
;
ii
<
static_cast
<
mwIndex
>
(
nA
);
ii
++
)
{
...
...
@@ -93,12 +93,12 @@ sparse_hessian_times_B_kronecker_C(const mwIndex *isparseA, const mwIndex *jspar
size_t
mA
,
size_t
nA
,
size_t
mB
,
size_t
nB
,
size_t
mC
,
size_t
nC
,
int
number_of_threads
)
{
/*
** Loop over the columns of
kron(B,B)
(or of the result matrix D).
** Loop over the columns of
B⊗B
(or of the result matrix D).
*/
#if USE_OMP
# pragma omp parallel for num_threads(number_of_threads)
#endif
for
(
mwIndex
jj
=
0
;
jj
<
static_cast
<
mwIndex
>
(
nB
*
nC
);
jj
++
)
// column of
kron(B,C)
index.
for
(
mwIndex
jj
=
0
;
jj
<
static_cast
<
mwIndex
>
(
nB
*
nC
);
jj
++
)
// column of
B⊗C
index.
{
// Uncomment the following line to check if all processors are used.
#if DEBUG_OMP
...
...
@@ -111,7 +111,7 @@ sparse_hessian_times_B_kronecker_C(const mwIndex *isparseA, const mwIndex *jspar
mwIndex
iv
=
0
;
int
nz_in_column_ii_of_A
=
0
;
/*
** Loop over the rows of
kron(B,C)
(column jj).
** Loop over the rows of
B⊗C
(column jj).
*/
for
(
mwIndex
ii
=
0
;
ii
<
static_cast
<
mwIndex
>
(
nA
);
ii
++
)
{
...
...
@@ -153,14 +153,14 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
size_t
mB
=
mxGetM
(
prhs
[
1
]);
size_t
nB
=
mxGetN
(
prhs
[
1
]);
size_t
mC
,
nC
;
if
(
nrhs
==
4
)
// A
*kron
(B
,
C) is to be computed.
if
(
nrhs
==
4
)
// A
·
(B
⊗
C) is to be computed.
{
mC
=
mxGetM
(
prhs
[
2
]);
nC
=
mxGetN
(
prhs
[
2
]);
if
(
mB
*
mC
!=
nA
)
DYN_MEX_FUNC_ERR_MSG_TXT
(
"Input dimension error!"
);
}
else
// A
*kron
(B
,
B) is to be computed.
else
// A
·
(B
⊗
B) is to be computed.
{
if
(
mB
*
mB
!=
nA
)
DYN_MEX_FUNC_ERR_MSG_TXT
(
"Input dimension error!"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment