2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2011,2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 %Exception std::out_of_range(SIP_IndexError) {
44 PyErr_SetString(PyExc_IndexError, sipExceptionRef.what());
49 template<T> class RealVector /NoDefaultCtors/ {
58 T operator[] (unsigned int i) throw (std::out_of_range);
61 size_t size = PyOS_snprintf(NULL, 0, "Vector [%f, %f, %f]", sipCpp->x, sipCpp->y, sipCpp->z);
63 PyOS_snprintf(str, size + 1, "Vector [%f, %f, %f]", sipCpp->x, sipCpp->y, sipCpp->z);
65 return PyUnicode_FromString(str);
69 template<T, Adaptor, Inner> class Array /NoDefaultCtors/ {
75 Adaptor operator[] (unsigned int i) throw (std::out_of_range);
76 SIP_SSIZE_T __len__();
78 sipRes = sipCpp->len();
82 class Matrix /NoDefaultCtors/ {
88 py_rvec __getitem__(int) throw (std::out_of_range);
91 sipRes = new py_rvec(sipCpp->get(a0));
92 } catch (const std::out_of_range &e) {
95 PyErr_SetString(PyExc_IndexError, e.what());
99 double __getitem__(SIP_PYTUPLE) throw (std::out_of_range);
102 if (PyArg_ParseTuple(a0, "nn", &i, &j))
104 sipRes = sipCpp->get(i, j);
105 } catch (const std::out_of_range &e) {
108 PyErr_SetString(PyExc_IndexError, e.what());
116 typedef double* rvec;
117 typedef double* dvec;
118 typedef double** matrix;
119 typedef double** tensor;
121 typedef int** imatrix;
123 typedef RealVector<double> py_rvec;
124 typedef Array<double, py_rvec, rvec> rvecs;