Commit c99e7abd authored by Michael Sherman's avatar Michael Sherman
Browse files

Eliminate some VC++ build problems via the usual expedient of explicit casts...

Eliminate some VC++ build problems via the usual expedient of explicit casts from unsigned to signed and from double to float. TNT Arrays apparently can't be indexed with unsigned because VC++ finds something ambiguous then above their operator[] methods.
parent aca30cd8
...@@ -467,14 +467,14 @@ static void markShakeClusterInvalid(ShakeCluster& cluster, map<int, ShakeCluster ...@@ -467,14 +467,14 @@ static void markShakeClusterInvalid(ShakeCluster& cluster, map<int, ShakeCluster
static void findRigidClusters(gpuContext gpu, const vector<int>& firstAtom, const vector<int>& secondAtom, const vector<int>& constraintIndices) static void findRigidClusters(gpuContext gpu, const vector<int>& firstAtom, const vector<int>& secondAtom, const vector<int>& constraintIndices)
{ {
vector<map<int, int> > atomConstraints(firstAtom.size()); vector<map<int, int> > atomConstraints(firstAtom.size());
for (int i = 0; i < constraintIndices.size(); i++) { for (int i = 0; i < (int)constraintIndices.size(); i++) {
atomConstraints[firstAtom[i]][secondAtom[i]] = constraintIndices[i]; atomConstraints[firstAtom[i]][secondAtom[i]] = constraintIndices[i];
atomConstraints[secondAtom[i]][firstAtom[i]] = constraintIndices[i]; atomConstraints[secondAtom[i]][firstAtom[i]] = constraintIndices[i];
} }
vector<vector<int> > rigidClusters; vector<vector<int> > rigidClusters;
int totalConstraints = 0; int totalConstraints = 0;
int totalMatrixElements = 0; int totalMatrixElements = 0;
for (int i = 0; i < firstAtom.size(); i++) { for (int i = 0; i < (int)firstAtom.size(); i++) {
if (atomConstraints[i].size() < 2) if (atomConstraints[i].size() < 2)
continue; continue;
......
...@@ -227,10 +227,10 @@ static void initInverseMatrices(gpuContext gpu) ...@@ -227,10 +227,10 @@ static void initInverseMatrices(gpuContext gpu)
r[j].z *= invLength; r[j].z *= invLength;
} }
Array2D<double> matrix(size, size); Array2D<double> matrix(size, size);
for (unsigned int j = 0; j < size; j++) { for (int j = 0; j < (int)size; j++) {
int constraintj = (*gpu->psRigidClusterConstraints)[startIndex+j]; int constraintj = (*gpu->psRigidClusterConstraints)[startIndex+j];
int2 atomsj = (*gpu->psLincsAtoms)[constraintj]; int2 atomsj = (*gpu->psLincsAtoms)[constraintj];
for (unsigned int k = 0; k < size; k++) { for (int k = 0; k < (int)size; k++) {
int constraintk = (*gpu->psRigidClusterConstraints)[startIndex+k]; int constraintk = (*gpu->psRigidClusterConstraints)[startIndex+k];
int2 atomsk = (*gpu->psLincsAtoms)[constraintk]; int2 atomsk = (*gpu->psLincsAtoms)[constraintk];
float invMassj0 = (*gpu->psVelm4)[atomsj.x].w; float invMassj0 = (*gpu->psVelm4)[atomsj.x].w;
...@@ -260,12 +260,12 @@ static void initInverseMatrices(gpuContext gpu) ...@@ -260,12 +260,12 @@ static void initInverseMatrices(gpuContext gpu)
svd.getV(v); svd.getV(v);
svd.getSingularValues(w); svd.getSingularValues(w);
double singularValueCutoff = 0.01*w[0]; double singularValueCutoff = 0.01*w[0];
for (unsigned int j = 0; j < size; j++) for (int j = 0; j < (int)size; j++)
w[j] = (w[j] < singularValueCutoff ? 0.0 : 1.0/w[j]); w[j] = (w[j] < singularValueCutoff ? 0.0 : 1.0/w[j]);
for (unsigned int j = 0; j < size; j++) { for (int j = 0; j < (int)size; j++) {
for (unsigned int k = 0; k < size; k++) { for (int k = 0; k < (int)size; k++) {
matrix[j][k] = 0.0; matrix[j][k] = 0.0;
for (unsigned int m = 0; m < size; m++) for (int m = 0; m < (int)size; m++)
matrix[j][k] += v[j][m]*w[m]*u[k][m]; matrix[j][k] += v[j][m]*w[m]*u[k][m];
} }
} }
...@@ -273,13 +273,13 @@ static void initInverseMatrices(gpuContext gpu) ...@@ -273,13 +273,13 @@ static void initInverseMatrices(gpuContext gpu)
// Record the inverted matrix. // Record the inverted matrix.
(*gpu->psRigidClusterMatrixIndex)[i] = elementIndex; (*gpu->psRigidClusterMatrixIndex)[i] = elementIndex;
for (unsigned int j = 0; j < size; j++) for (int j = 0; j < (int)size; j++)
{ {
float distance1 = (*gpu->psLincsDistance)[(*gpu->psRigidClusterConstraints)[startIndex+j]].w; float distance1 = (*gpu->psLincsDistance)[(*gpu->psRigidClusterConstraints)[startIndex+j]].w;
for (unsigned int k = 0; k < size; k++) for (int k = 0; k < (int)size; k++)
{ {
float distance2 = (*gpu->psLincsDistance)[(*gpu->psRigidClusterConstraints)[startIndex+k]].w; float distance2 = (*gpu->psLincsDistance)[(*gpu->psRigidClusterConstraints)[startIndex+k]].w;
(*gpu->psRigidClusterMatrix)[elementIndex++] = matrix[k][j]*distance1/distance2; (*gpu->psRigidClusterMatrix)[elementIndex++] = (float)(matrix[k][j]*distance1/distance2);
} }
} }
} }
......
...@@ -359,8 +359,8 @@ int ReferenceRigidShakeAlgorithm::apply( int numberOfAtoms, RealOpenMM** atomCoo ...@@ -359,8 +359,8 @@ int ReferenceRigidShakeAlgorithm::apply( int numberOfAtoms, RealOpenMM** atomCoo
r[j][2] *= invLength; r[j][2] *= invLength;
} }
Array2D<double> matrix(size, size); Array2D<double> matrix(size, size);
for (unsigned int j = 0; j < size; j++) { for (int j = 0; j < (int)size; j++) {
for (unsigned int k = 0; k < size; k++) { for (int k = 0; k < (int)size; k++) {
double dot; double dot;
int atomj0 = _atomIndices[cluster[j]][0]; int atomj0 = _atomIndices[cluster[j]][0];
int atomj1 = _atomIndices[cluster[j]][1]; int atomj1 = _atomIndices[cluster[j]][1];
...@@ -390,20 +390,20 @@ int ReferenceRigidShakeAlgorithm::apply( int numberOfAtoms, RealOpenMM** atomCoo ...@@ -390,20 +390,20 @@ int ReferenceRigidShakeAlgorithm::apply( int numberOfAtoms, RealOpenMM** atomCoo
svd.getV(v); svd.getV(v);
svd.getSingularValues(w); svd.getSingularValues(w);
double singularValueCutoff = 0.01*w[0]; double singularValueCutoff = 0.01*w[0];
for (unsigned int j = 0; j < size; j++) for (int j = 0; j < (int)size; j++)
w[j] = (w[j] < singularValueCutoff ? 0.0 : 1.0/w[j]); w[j] = (w[j] < singularValueCutoff ? 0.0 : 1.0/w[j]);
for (unsigned int j = 0; j < size; j++) { for (int j = 0; j < (int)size; j++) {
for (unsigned int k = 0; k < size; k++) { for (int k = 0; k < (int)size; k++) {
matrix[j][k] = 0.0; matrix[j][k] = 0.0;
for (unsigned int m = 0; m < size; m++) for (int m = 0; m < (int)size; m++)
matrix[j][k] += v[j][m]*w[m]*u[k][m]; matrix[j][k] += v[j][m]*w[m]*u[k][m];
} }
} }
// Record the inverted matrix. // Record the inverted matrix.
for (unsigned int j = 0; j < size; j++) for (int j = 0; j < (int)size; j++)
for (unsigned int k = 0; k < size; k++) for (int k = 0; k < (int)size; k++)
_matrices[i][j][k] = (RealOpenMM)matrix[j][k]*_distance[cluster[k]]/_distance[cluster[j]]; _matrices[i][j][k] = (RealOpenMM)matrix[j][k]*_distance[cluster[k]]/_distance[cluster[j]];
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment