Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
bdd0267d
Commit
bdd0267d
authored
Jul 14, 2015
by
peastman
Browse files
Merge pull request #1037 from peastman/ccma
Fixed error in constructing CCMA matrix
parents
3d64a10d
3cf4e73a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
platforms/reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp
...s/reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp
+19
-12
No files found.
platforms/reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp
View file @
bdd0267d
...
...
@@ -33,21 +33,19 @@
#include "openmm/Vec3.h"
#include "openmm/internal/ThreadPool.h"
#include <map>
#include <utility>
using
std
::
map
;
using
std
::
pair
;
using
std
::
vector
;
using
std
::
set
;
using
namespace
OpenMM
;
using
namespace
std
;
// This class extracts columns from the inverse matrix one at a time. It is done in parallel,
// since this can be very slow.
class
ExtractMatrixTask
:
public
ThreadPool
::
Task
{
public:
ExtractMatrixTask
(
int
numConstraints
,
vector
<
vector
<
pair
<
int
,
RealOpenMM
>
>
>&
m
atrix
,
const
vector
<
RealOpenMM
>&
distance
,
RealOpenMM
elementCutoff
,
ExtractMatrixTask
(
int
numConstraints
,
vector
<
vector
<
pair
<
int
,
RealOpenMM
>
>
>&
transposedM
atrix
,
const
vector
<
RealOpenMM
>&
distance
,
RealOpenMM
elementCutoff
,
const
int
*
qRowStart
,
const
int
*
qColIndex
,
const
int
*
rRowStart
,
const
int
*
rColIndex
,
const
double
*
qValue
,
const
double
*
rValue
)
:
numConstraints
(
numConstraints
),
matrix
(
m
atrix
),
distance
(
distance
),
elementCutoff
(
elementCutoff
),
qRowStart
(
qRowStart
),
qColIndex
(
qColIndex
),
numConstraints
(
numConstraints
),
transposedMatrix
(
transposedM
atrix
),
distance
(
distance
),
elementCutoff
(
elementCutoff
),
qRowStart
(
qRowStart
),
qColIndex
(
qColIndex
),
rRowStart
(
rRowStart
),
rColIndex
(
rColIndex
),
qValue
(
qValue
),
rValue
(
rValue
)
{
}
...
...
@@ -61,15 +59,15 @@ public:
QUERN_multiply_with_q_transpose
(
numConstraints
,
qRowStart
,
qColIndex
,
qValue
,
&
rhs
[
0
]);
QUERN_solve_with_r
(
numConstraints
,
rRowStart
,
rColIndex
,
rValue
,
&
rhs
[
0
],
&
rhs
[
0
]);
for
(
int
j
=
0
;
j
<
numConstraints
;
j
++
)
{
double
value
=
rhs
[
j
]
*
distance
[
j
]
/
distance
[
i
];
double
value
=
rhs
[
j
]
*
distance
[
i
]
/
distance
[
j
];
if
(
FABS
((
RealOpenMM
)
value
)
>
elementCutoff
)
m
atrix
[
i
].
push_back
(
pair
<
int
,
RealOpenMM
>
(
j
,
(
RealOpenMM
)
value
));
transposedM
atrix
[
i
].
push_back
(
pair
<
int
,
RealOpenMM
>
(
j
,
(
RealOpenMM
)
value
));
}
}
}
private:
int
numConstraints
;
vector
<
vector
<
pair
<
int
,
RealOpenMM
>
>
>&
m
atrix
;
vector
<
vector
<
pair
<
int
,
RealOpenMM
>
>
>&
transposedM
atrix
;
const
vector
<
RealOpenMM
>&
distance
;
RealOpenMM
elementCutoff
;
const
int
*
qRowStart
,
*
qColIndex
,
*
rRowStart
,
*
rColIndex
;
...
...
@@ -194,12 +192,21 @@ ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
double
*
qValue
,
*
rValue
;
QUERN_compute_qr
(
numberOfConstraints
,
numberOfConstraints
,
&
matrixRowStart
[
0
],
&
matrixColIndex
[
0
],
&
matrixValue
[
0
],
NULL
,
&
qRowStart
,
&
qColIndex
,
&
qValue
,
&
rRowStart
,
&
rColIndex
,
&
rValue
);
vector
<
double
>
rhs
(
numberOfConstraints
);
vector
<
vector
<
pair
<
int
,
RealOpenMM
>
>
>
transposedMatrix
(
numberOfConstraints
);
_matrix
.
resize
(
numberOfConstraints
);
ThreadPool
threads
;
ExtractMatrixTask
task
(
numberOfConstraints
,
_m
atrix
,
_distance
,
_elementCutoff
,
qRowStart
,
qColIndex
,
rRowStart
,
rColIndex
,
qValue
,
rValue
);
ExtractMatrixTask
task
(
numberOfConstraints
,
transposedM
atrix
,
_distance
,
_elementCutoff
,
qRowStart
,
qColIndex
,
rRowStart
,
rColIndex
,
qValue
,
rValue
);
threads
.
execute
(
task
);
threads
.
waitForThreads
();
// For purposes of thread safety we extracted the matrix in transposed form, so we need to transpose it again.
for
(
int
i
=
0
;
i
<
numberOfConstraints
;
i
++
)
{
for
(
int
j
=
0
;
j
<
transposedMatrix
[
i
].
size
();
j
++
)
{
pair
<
int
,
RealOpenMM
>
value
=
transposedMatrix
[
i
][
j
];
_matrix
[
value
.
first
].
push_back
(
make_pair
(
i
,
value
.
second
));
}
}
QUERN_free_result
(
qRowStart
,
qColIndex
,
qValue
);
QUERN_free_result
(
rRowStart
,
rColIndex
,
rValue
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment