Commit 70ba177d authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed compilation errors on Windows

parent 86aacbd8
/* C header file for Hilbert curve functions */ /* C header file for Hilbert curve functions */
#if !defined(_hilbert_h_) #if !defined(_hilbert_h_)
#define _hilbert_h_ #define _hilbert_h_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
/* define the bitmask_t type as an integer of sufficient size */ /* define the bitmask_t type as an integer of sufficient size */
typedef unsigned long long bitmask_t; typedef unsigned long long bitmask_t;
/* define the halfmask_t type as an integer of 1/2 the size of bitmask_t */ /* define the halfmask_t type as an integer of 1/2 the size of bitmask_t */
typedef unsigned int halfmask_t; typedef unsigned int halfmask_t;
#else #if defined(OPENMM_BUILDING_SHARED_LIBRARY)
#include <stdint.h> #define WINDOWS_EXPORT __declspec(dllexport)
/* define the bitmask_t type as an integer of sufficient size */ #endif
typedef uint64_t bitmask_t; #else
/* define the halfmask_t type as an integer of 1/2 the size of bitmask_t */ #include <stdint.h>
typedef uint32_t halfmask_t; /* define the bitmask_t type as an integer of sufficient size */
#endif typedef uint64_t bitmask_t;
/* define the halfmask_t type as an integer of 1/2 the size of bitmask_t */
/***************************************************************** typedef uint32_t halfmask_t;
* hilbert_i2c #define WINDOWS_EXPORT
* #endif
* Convert an index into a Hilbert curve to a set of coordinates.
* Inputs: /*****************************************************************
* nDims: Number of coordinate axes. * hilbert_i2c
* nBits: Number of bits per axis. *
* index: The index, contains nDims*nBits bits (so nDims*nBits must be <= 8*sizeof(bitmask_t)). * Convert an index into a Hilbert curve to a set of coordinates.
* Outputs: * Inputs:
* coord: The list of nDims coordinates, each with nBits bits. * nDims: Number of coordinate axes.
* Assumptions: * nBits: Number of bits per axis.
* nDims*nBits <= (sizeof index) * (bits_per_byte) * index: The index, contains nDims*nBits bits (so nDims*nBits must be <= 8*sizeof(bitmask_t)).
*/ * Outputs:
* coord: The list of nDims coordinates, each with nBits bits.
void hilbert_i2c(unsigned nDims, unsigned nBits, bitmask_t index, bitmask_t coord[]); * Assumptions:
* nDims*nBits <= (sizeof index) * (bits_per_byte)
/***************************************************************** */
* hilbert_c2i
* void WINDOWS_EXPORT hilbert_i2c(unsigned nDims, unsigned nBits, bitmask_t index, bitmask_t coord[]);
* Convert coordinates of a point on a Hilbert curve to its index.
* Inputs: /*****************************************************************
* nDims: Number of coordinates. * hilbert_c2i
* nBits: Number of bits/coordinate. *
* coord: Array of n nBits-bit coordinates. * Convert coordinates of a point on a Hilbert curve to its index.
* Outputs: * Inputs:
* index: Output index value. nDims*nBits bits. * nDims: Number of coordinates.
* Assumptions: * nBits: Number of bits/coordinate.
* nDims*nBits <= (sizeof bitmask_t) * (bits_per_byte) * coord: Array of n nBits-bit coordinates.
*/ * Outputs:
* index: Output index value. nDims*nBits bits.
bitmask_t hilbert_c2i(unsigned nDims, unsigned nBits, bitmask_t const coord[]); * Assumptions:
* nDims*nBits <= (sizeof bitmask_t) * (bits_per_byte)
/***************************************************************** */
* hilbert_cmp, hilbert_ieee_cmp
* bitmask_t WINDOWS_EXPORT hilbert_c2i(unsigned nDims, unsigned nBits, bitmask_t const coord[]);
* Determine which of two points lies further along the Hilbert curve
* Inputs: /*****************************************************************
* nDims: Number of coordinates. * hilbert_cmp, hilbert_ieee_cmp
* nBytes: Number of bytes of storage/coordinate (hilbert_cmp only) *
* nBits: Number of bits/coordinate. (hilbert_cmp only) * Determine which of two points lies further along the Hilbert curve
* coord1: Array of nDims nBytes-byte coordinates (or doubles for ieee_cmp). * Inputs:
* coord2: Array of nDims nBytes-byte coordinates (or doubles for ieee_cmp). * nDims: Number of coordinates.
* Return value: * nBytes: Number of bytes of storage/coordinate (hilbert_cmp only)
* -1, 0, or 1 according to whether * nBits: Number of bits/coordinate. (hilbert_cmp only)
coord1<coord2, coord1==coord2, coord1>coord2 * coord1: Array of nDims nBytes-byte coordinates (or doubles for ieee_cmp).
* Assumptions: * coord2: Array of nDims nBytes-byte coordinates (or doubles for ieee_cmp).
* nBits <= (sizeof bitmask_t) * (bits_per_byte) * Return value:
*/ * -1, 0, or 1 according to whether
coord1<coord2, coord1==coord2, coord1>coord2
int hilbert_cmp(unsigned nDims, unsigned nBytes, unsigned nBits, void const* coord1, void const* coord2); * Assumptions:
int hilbert_ieee_cmp(unsigned nDims, double const* coord1, double const* coord2); * nBits <= (sizeof bitmask_t) * (bits_per_byte)
*/
/*****************************************************************
* hilbert_box_vtx int WINDOWS_EXPORT hilbert_cmp(unsigned nDims, unsigned nBytes, unsigned nBits, void const* coord1, void const* coord2);
* int WINDOWS_EXPORT hilbert_ieee_cmp(unsigned nDims, double const* coord1, double const* coord2);
* Determine the first or last vertex of a box to lie on a Hilbert curve
* Inputs: /*****************************************************************
* nDims: Number of coordinates. * hilbert_box_vtx
* nBytes: Number of bytes/coordinate. *
* nBits: Number of bits/coordinate. (hilbert_cmp only) * Determine the first or last vertex of a box to lie on a Hilbert curve
* findMin: Is it the least vertex sought? * Inputs:
* coord1: Array of nDims nBytes-byte coordinates - one corner of box * nDims: Number of coordinates.
* coord2: Array of nDims nBytes-byte coordinates - opposite corner * nBytes: Number of bytes/coordinate.
* Output: * nBits: Number of bits/coordinate. (hilbert_cmp only)
* c1 and c2 modified to refer to selected corner * findMin: Is it the least vertex sought?
* value returned is log2 of size of largest power-of-two-aligned box that * coord1: Array of nDims nBytes-byte coordinates - one corner of box
* contains the selected corner and no other corners * coord2: Array of nDims nBytes-byte coordinates - opposite corner
* Assumptions: * Output:
* nBits <= (sizeof bitmask_t) * (bits_per_byte) * c1 and c2 modified to refer to selected corner
*/ * value returned is log2 of size of largest power-of-two-aligned box that
unsigned * contains the selected corner and no other corners
hilbert_box_vtx(unsigned nDims, unsigned nBytes, unsigned nBits, * Assumptions:
int findMin, void* c1, void* c2); * nBits <= (sizeof bitmask_t) * (bits_per_byte)
unsigned */
hilbert_ieee_box_vtx(unsigned nDims, unsigned WINDOWS_EXPORT
int findMin, double* c1, double* c2); hilbert_box_vtx(unsigned nDims, unsigned nBytes, unsigned nBits,
int findMin, void* c1, void* c2);
/***************************************************************** unsigned WINDOWS_EXPORT
* hilbert_box_pt hilbert_ieee_box_vtx(unsigned nDims,
* int findMin, double* c1, double* c2);
* Determine the first or last point of a box to lie on a Hilbert curve
* Inputs: /*****************************************************************
* nDims: Number of coordinates. * hilbert_box_pt
* nBytes: Number of bytes/coordinate. *
* nBits: Number of bits/coordinate. * Determine the first or last point of a box to lie on a Hilbert curve
* findMin: Is it the least vertex sought? * Inputs:
* coord1: Array of nDims nBytes-byte coordinates - one corner of box * nDims: Number of coordinates.
* coord2: Array of nDims nBytes-byte coordinates - opposite corner * nBytes: Number of bytes/coordinate.
* Output: * nBits: Number of bits/coordinate.
* c1 and c2 modified to refer to least point * findMin: Is it the least vertex sought?
* Assumptions: * coord1: Array of nDims nBytes-byte coordinates - one corner of box
* nBits <= (sizeof bitmask_t) * (bits_per_byte) * coord2: Array of nDims nBytes-byte coordinates - opposite corner
*/ * Output:
unsigned * c1 and c2 modified to refer to least point
hilbert_box_pt(unsigned nDims, unsigned nBytes, unsigned nBits, * Assumptions:
int findMin, void* coord1, void* coord2); * nBits <= (sizeof bitmask_t) * (bits_per_byte)
unsigned */
hilbert_ieee_box_pt(unsigned nDims, unsigned WINDOWS_EXPORT
int findMin, double* c1, double* c2); hilbert_box_pt(unsigned nDims, unsigned nBytes, unsigned nBits,
int findMin, void* coord1, void* coord2);
/***************************************************************** unsigned WINDOWS_EXPORT
* hilbert_nextinbox hilbert_ieee_box_pt(unsigned nDims,
* int findMin, double* c1, double* c2);
* Determine the first point of a box after a given point to lie on a Hilbert curve
* Inputs: /*****************************************************************
* nDims: Number of coordinates. * hilbert_nextinbox
* nBytes: Number of bytes/coordinate. *
* nBits: Number of bits/coordinate. * Determine the first point of a box after a given point to lie on a Hilbert curve
* findPrev: Is the previous point sought? * Inputs:
* coord1: Array of nDims nBytes-byte coordinates - one corner of box * nDims: Number of coordinates.
* coord2: Array of nDims nBytes-byte coordinates - opposite corner * nBytes: Number of bytes/coordinate.
* point: Array of nDims nBytes-byte coordinates - lower bound on point returned * nBits: Number of bits/coordinate.
* * findPrev: Is the previous point sought?
* Output: * coord1: Array of nDims nBytes-byte coordinates - one corner of box
if returns 1: * coord2: Array of nDims nBytes-byte coordinates - opposite corner
* c1 and c2 modified to refer to least point after "point" in box * point: Array of nDims nBytes-byte coordinates - lower bound on point returned
else returns 0: *
arguments unchanged; "point" is beyond the last point of the box * Output:
* Assumptions: if returns 1:
* nBits <= (sizeof bitmask_t) * (bits_per_byte) * c1 and c2 modified to refer to least point after "point" in box
*/ else returns 0:
int arguments unchanged; "point" is beyond the last point of the box
hilbert_nextinbox(unsigned nDims, unsigned nBytes, unsigned nBits, * Assumptions:
int findPrev, void* coord1, void* coord2, * nBits <= (sizeof bitmask_t) * (bits_per_byte)
void const* point); */
int WINDOWS_EXPORT
/***************************************************************** hilbert_nextinbox(unsigned nDims, unsigned nBytes, unsigned nBits,
* hilbert_incr int findPrev, void* coord1, void* coord2,
* void const* point);
* Advance from one point to its successor on a Hilbert curve
* Inputs: /*****************************************************************
* nDims: Number of coordinates. * hilbert_incr
* nBits: Number of bits/coordinate. *
* coord: Array of nDims nBits-bit coordinates. * Advance from one point to its successor on a Hilbert curve
* Output: * Inputs:
* coord: Next point on Hilbert curve * nDims: Number of coordinates.
* Assumptions: * nBits: Number of bits/coordinate.
* nBits <= (sizeof bitmask_t) * (bits_per_byte) * coord: Array of nDims nBits-bit coordinates.
*/ * Output:
* coord: Next point on Hilbert curve
void * Assumptions:
hilbert_incr(unsigned nDims, unsigned nBits, bitmask_t coord[]); * nBits <= (sizeof bitmask_t) * (bits_per_byte)
*/
#ifdef __cplusplus
} void WINDOWS_EXPORT
#endif hilbert_incr(unsigned nDims, unsigned nBits, bitmask_t coord[]);
#endif /* _hilbert_h_ */ #ifdef __cplusplus
}
#endif
#endif /* _hilbert_h_ */
...@@ -135,7 +135,7 @@ bitTranspose(unsigned nDims, unsigned nBits, bitmask_t inCoords) ...@@ -135,7 +135,7 @@ bitTranspose(unsigned nDims, unsigned nBits, bitmask_t inCoords)
* Assumptions: * Assumptions:
* nDims*nBits <= (sizeof index) * (bits_per_byte) * nDims*nBits <= (sizeof index) * (bits_per_byte)
*/ */
void void WINDOWS_EXPORT
hilbert_i2c(unsigned nDims, unsigned nBits, bitmask_t index, bitmask_t coord[]) hilbert_i2c(unsigned nDims, unsigned nBits, bitmask_t index, bitmask_t coord[])
{ {
if (nDims > 1) if (nDims > 1)
...@@ -193,7 +193,7 @@ hilbert_i2c(unsigned nDims, unsigned nBits, bitmask_t index, bitmask_t coord[]) ...@@ -193,7 +193,7 @@ hilbert_i2c(unsigned nDims, unsigned nBits, bitmask_t index, bitmask_t coord[])
* Assumptions: * Assumptions:
* nDims*nBits <= (sizeof bitmask_t) * (bits_per_byte) * nDims*nBits <= (sizeof bitmask_t) * (bits_per_byte)
*/ */
bitmask_t bitmask_t WINDOWS_EXPORT
hilbert_c2i(unsigned nDims, unsigned nBits, bitmask_t const coord[]) hilbert_c2i(unsigned nDims, unsigned nBits, bitmask_t const coord[])
{ {
if (nDims > 1) if (nDims > 1)
...@@ -562,7 +562,7 @@ hilbert_cmp_work(unsigned nDims, unsigned nBytes, unsigned nBits, ...@@ -562,7 +562,7 @@ hilbert_cmp_work(unsigned nDims, unsigned nBytes, unsigned nBits,
return 0; return 0;
} }
int int WINDOWS_EXPORT
hilbert_cmp(unsigned nDims, unsigned nBytes, unsigned nBits, hilbert_cmp(unsigned nDims, unsigned nBytes, unsigned nBits,
void const* c1, void const* c2) void const* c1, void const* c2)
{ {
...@@ -573,7 +573,7 @@ hilbert_cmp(unsigned nDims, unsigned nBytes, unsigned nBits, ...@@ -573,7 +573,7 @@ hilbert_cmp(unsigned nDims, unsigned nBytes, unsigned nBits,
0, bits, bits, getIntBits); 0, bits, bits, getIntBits);
} }
int int WINDOWS_EXPORT
hilbert_ieee_cmp(unsigned nDims, double const* c1, double const* c2) hilbert_ieee_cmp(unsigned nDims, double const* c1, double const* c2)
{ {
unsigned rotation, max; unsigned rotation, max;
...@@ -673,7 +673,7 @@ hilbert_box_vtx_work(unsigned nDims, unsigned nBytes, unsigned nBits, ...@@ -673,7 +673,7 @@ hilbert_box_vtx_work(unsigned nDims, unsigned nBytes, unsigned nBits,
return y; return y;
} }
unsigned unsigned WINDOWS_EXPORT
hilbert_box_vtx(unsigned nDims, unsigned nBytes, unsigned nBits, hilbert_box_vtx(unsigned nDims, unsigned nBytes, unsigned nBits,
int findMin, void* c1, void* c2) int findMin, void* c1, void* c2)
{ {
...@@ -684,7 +684,7 @@ hilbert_box_vtx(unsigned nDims, unsigned nBytes, unsigned nBits, ...@@ -684,7 +684,7 @@ hilbert_box_vtx(unsigned nDims, unsigned nBytes, unsigned nBits,
0, bits, bits, getIntBits); 0, bits, bits, getIntBits);
} }
unsigned unsigned WINDOWS_EXPORT
hilbert_ieee_box_vtx(unsigned nDims, hilbert_ieee_box_vtx(unsigned nDims,
int findMin, double* c1, double* c2) int findMin, double* c1, double* c2)
{ {
...@@ -722,7 +722,7 @@ hilbert_ieee_box_vtx(unsigned nDims, ...@@ -722,7 +722,7 @@ hilbert_ieee_box_vtx(unsigned nDims,
* Assumptions: * Assumptions:
* nBits <= (sizeof bitmask_t) * (bits_per_byte) * nBits <= (sizeof bitmask_t) * (bits_per_byte)
*/ */
unsigned unsigned WINDOWS_EXPORT
hilbert_box_pt_work(unsigned nDims, unsigned nBytes, unsigned nBits, hilbert_box_pt_work(unsigned nDims, unsigned nBytes, unsigned nBits,
int findMin, int findMin,
unsigned max, unsigned y, unsigned max, unsigned y,
...@@ -783,7 +783,7 @@ hilbert_box_pt_work(unsigned nDims, unsigned nBytes, unsigned nBits, ...@@ -783,7 +783,7 @@ hilbert_box_pt_work(unsigned nDims, unsigned nBytes, unsigned nBits,
return smearSum; return smearSum;
} }
unsigned unsigned WINDOWS_EXPORT
hilbert_box_pt(unsigned nDims, unsigned nBytes, unsigned nBits, hilbert_box_pt(unsigned nDims, unsigned nBytes, unsigned nBits,
int findMin, void* c1, void* c2) int findMin, void* c1, void* c2)
{ {
...@@ -795,7 +795,7 @@ hilbert_box_pt(unsigned nDims, unsigned nBytes, unsigned nBits, ...@@ -795,7 +795,7 @@ hilbert_box_pt(unsigned nDims, unsigned nBytes, unsigned nBits,
getIntBits, propogateIntBits); getIntBits, propogateIntBits);
} }
unsigned unsigned WINDOWS_EXPORT
hilbert_ieee_box_pt(unsigned nDims, hilbert_ieee_box_pt(unsigned nDims,
int findMin, double* c1, double* c2) int findMin, double* c1, double* c2)
{ {
...@@ -851,7 +851,7 @@ hilbert_ieee_box_pt(unsigned nDims, ...@@ -851,7 +851,7 @@ hilbert_ieee_box_pt(unsigned nDims,
* Assumptions: * Assumptions:
* nBits <= (sizeof bitmask_t) * (bits_per_byte) * nBits <= (sizeof bitmask_t) * (bits_per_byte)
*/ */
int int WINDOWS_EXPORT
hilbert_nextinbox(unsigned nDims, unsigned nBytes, unsigned nBits, hilbert_nextinbox(unsigned nDims, unsigned nBytes, unsigned nBits,
int findPrev, void* c1V, void* c2V, void const* ptV) int findPrev, void* c1V, void* c2V, void const* ptV)
{ {
...@@ -1045,7 +1045,7 @@ hilbert_nextinbox(unsigned nDims, unsigned nBytes, unsigned nBits, ...@@ -1045,7 +1045,7 @@ hilbert_nextinbox(unsigned nDims, unsigned nBytes, unsigned nBits,
* nBits <= (sizeof bitmask_t) * (bits_per_byte) * nBits <= (sizeof bitmask_t) * (bits_per_byte)
*/ */
void void WINDOWS_EXPORT
hilbert_incr(unsigned nDims, unsigned nBits, bitmask_t coord[]) hilbert_incr(unsigned nDims, unsigned nBits, bitmask_t coord[])
{ {
bitmask_t const one = 1; bitmask_t const one = 1;
......
...@@ -63,7 +63,7 @@ void compareStates(State& s1, State& s2) { ...@@ -63,7 +63,7 @@ void compareStates(State& s1, State& s2) {
ASSERT_EQUAL_VEC(b1, b2, TOL); ASSERT_EQUAL_VEC(b1, b2, TOL);
ASSERT_EQUAL_VEC(c1, c2, TOL); ASSERT_EQUAL_VEC(c1, c2, TOL);
for (map<string, double>::const_iterator iter = s1.getParameters().begin(); iter != s1.getParameters().end(); ++iter) for (map<string, double>::const_iterator iter = s1.getParameters().begin(); iter != s1.getParameters().end(); ++iter)
ASSERT_EQUAL(iter->second, s2.getParameters().at(iter->first)); ASSERT_EQUAL(iter->second, (*s2.getParameters().find(iter->first)).second);
} }
} }
......
...@@ -63,7 +63,7 @@ void compareStates(State& s1, State& s2) { ...@@ -63,7 +63,7 @@ void compareStates(State& s1, State& s2) {
ASSERT_EQUAL_VEC(b1, b2, TOL); ASSERT_EQUAL_VEC(b1, b2, TOL);
ASSERT_EQUAL_VEC(c1, c2, TOL); ASSERT_EQUAL_VEC(c1, c2, TOL);
for (map<string, double>::const_iterator iter = s1.getParameters().begin(); iter != s1.getParameters().end(); ++iter) for (map<string, double>::const_iterator iter = s1.getParameters().begin(); iter != s1.getParameters().end(); ++iter)
ASSERT_EQUAL(iter->second, s2.getParameters().at(iter->first)); ASSERT_EQUAL(iter->second, (*s2.getParameters().find(iter->first)).second);
} }
} }
......
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