#include "OpenMM.h"
#include "OpenMMAmoeba.h"
#include "../../../wrappers/OpenMMCWrapper.h"
#include "AmoebaOpenMMCWrapper.h"
#include <cstring>
#include <vector>
using namespace OpenMM;
using namespace std;
extern "C" {
/* OpenMM_2D_IntArray */
OPENMM_EXPORT OpenMM_2D_IntArray* OpenMM_2D_IntArray_create(int size) {
return reinterpret_cast<OpenMM_2D_IntArray*>(new vector<vector<int> >(size));
}
OPENMM_EXPORT void OpenMM_2D_IntArray_destroy(OpenMM_2D_IntArray* array) {
delete reinterpret_cast<vector<vector<int> >*>(array);
}
OPENMM_EXPORT int OpenMM_2D_IntArray_getSize(const OpenMM_2D_IntArray* array) {
return reinterpret_cast<const vector<vector<int> >*>(array)->size();
}
OPENMM_EXPORT void OpenMM_2D_IntArray_resize(OpenMM_2D_IntArray* array, int size) {
reinterpret_cast<vector<vector<int> >*>(array)->resize(size);
}
OPENMM_EXPORT void OpenMM_2D_IntArray_append(OpenMM_2D_IntArray* array, int index1, int value ) {
vector<vector<int> >* array2DInt = reinterpret_cast<vector<vector<int> >*>(array);
if( array2DInt->size() <= index1 ){
array2DInt->resize( index1+1 );
}
(*array2DInt)[index1].push_back( value );
}
OPENMM_EXPORT void OpenMM_2D_IntArray_set(OpenMM_2D_IntArray* array, int index1, int index2, int value) {
vector<vector<int> >* array2DInt = reinterpret_cast<vector<vector<int> >*>(array);
if( array2DInt->size() <= index1 ){
array2DInt->resize( index1+1 );
}
if( array2DInt[index1].size() <= index2 ){
array2DInt[index1].resize( index2+1 );
}
(*array2DInt)[index1][index2] = value;
}
OPENMM_EXPORT void OpenMM_2D_IntArray_get(const OpenMM_2D_IntArray* array, int index1, int index2, int* value) {
const vector<vector<int> >* array2DInt = reinterpret_cast<const vector<vector<int> >*>(array);
if ( array2DInt->size() <= index1 )
throw OpenMMException("OpenMM_2D_IntArray_get: first index out of range.");
if ( (*array2DInt)[index1].size() <= index2 )
throw OpenMMException("OpenMM_2D_IntArray_get: second index out of range.");
*value = (*array2DInt)[index1][index2];
}
/* OpenMM_3D_DoubleArray */
OPENMM_EXPORT OpenMM_3D_DoubleArray* OpenMM_3D_DoubleArray_create(int size1, int size2, int size3) {
int ii, jj;
std::vector< std::vector< std::vector<double> > >* v3D_Array = new std::vector<std::vector<std::vector<double> > >(size1);
for( ii = 0; ii < size1; ii++ ){
(*v3D_Array)[ii].resize(size2);
for( jj = 0; jj < size2; jj++ ){
(*v3D_Array)[ii][jj].resize(size3);
}
}
return reinterpret_cast<OpenMM_3D_DoubleArray*>(v3D_Array);
}
OPENMM_EXPORT void OpenMM_3D_DoubleArray_set(OpenMM_3D_DoubleArray* array, int index1, int index2, OpenMM_DoubleArray* values) {
unsigned int ii;
std::vector< std::vector< std::vector<double> > >* v3D_Array = reinterpret_cast<std::vector<std::vector<std::vector<double> > >*>(array);
std::vector<double> * value_array = reinterpret_cast<std::vector<double> *>(values);
for( ii = 0; ii < (*value_array).size(); ii++ ){
(*v3D_Array)[index1][index2][ii] = (*value_array)[ii];
}
}
OPENMM_EXPORT void OpenMM_3D_DoubleArray_destroy( OpenMM_3D_DoubleArray* array) {
delete reinterpret_cast<std::vector<std::vector<std::vector<double> > >*>(array);
}
}
/* */
OPENMM_EXPORT * _create(int size) {
return reinterpret_cast<*>(new vector<>(size));
}
OPENMM_EXPORT void _destroy(* array) {
delete reinterpret_cast<vector<>*>(array);
}
OPENMM_EXPORT int _getSize(const * array) {
return reinterpret_cast<const vector<>*>(array)->size();
}
OPENMM_EXPORT void _resize(* array, int size) {
reinterpret_cast<vector<>*>(array)->resize(size);
}
OPENMM_EXPORT void _append(* array, value) {
reinterpret_cast<vector<>*>(array)->push_back(value);
}
OPENMM_EXPORT void _set(* array, int index, value) {
(*reinterpret_cast<vector<>*>(array))[index] = value;
}
OPENMM_EXPORT _get(const * array, int index) {
return (*reinterpret_cast<const vector<>*>(array))[index];
}
/* OpenMM::
OPENMM_EXPORT void OpenMM_
delete reinterpret_cast<*>(target);
}
OPENMM_EXPORT OpenMM_
,
return reinterpret_cast<OpenMM_*>(new
,
}
OPENMM_EXPORT
,
,
};
1