parmed.unit.mymatrix module

Pure python inversion of small matrices, to avoid requiring numpy or similar in SimTK.

This is part of the OpenMM molecular simulation toolkit originating from Simbios, the NIH National Center for Physics-Based Simulation of Biological Structures at Stanford, funded under the NIH Roadmap for Medical Research, grant U54 GM072970. See https://simtk.org.

Portions copyright (c) 2012 Stanford University and the Authors. Authors: Christopher M. Bruns Contributors: Peter Eastman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

class parmed.unit.mymatrix.MyMatrix(collection)[source]

Bases: parmed.unit.mymatrix.MyVector

Pure python linear algebra matrix for internal matrix inversion in UnitSystem.

>>> m = MyMatrix([[1,0,],[0,1,]])
>>> print(m)
[[1, 0]
 [0, 1]]
>>> print(~m)
[[1.0, 0.0]
 [0.0, 1.0]]
>>> print(eye(5))
[[1, 0, 0, 0, 0]
 [0, 1, 0, 0, 0]
 [0, 0, 1, 0, 0]
 [0, 0, 0, 1, 0]
 [0, 0, 0, 0, 1]]
>>> m = eye(5)
>>> m[1][1]
1
>>> m[1:4]
MyMatrixTranspose([[0, 0, 0],[1, 0, 0],[0, 1, 0],[0, 0, 1],[0, 0, 0]])
>>> print(m[1:4])
[[0, 0, 0]
 [1, 0, 0]
 [0, 1, 0]
 [0, 0, 1]
 [0, 0, 0]]
>>> print(m[1:4][0:2])
[[0, 1]
 [0, 0]
 [0, 0]]
>>> m[1:4][0:2] = [[9,8],[7,6],[5,4]]
>>> print(m)
[[1, 0, 0, 0, 0]
 [9, 8, 0, 0, 0]
 [7, 6, 1, 0, 0]
 [5, 4, 0, 1, 0]
 [0, 0, 0, 0, 1]]

Methods

is_square

numCols

numRows

transpose

is_square()[source]
numCols()[source]
numRows()[source]
transpose()[source]
class parmed.unit.mymatrix.MyMatrixTranspose(collection)[source]

Bases: parmed.unit.mymatrix.MyMatrix

Methods

is_square

numCols

numRows

transpose

numCols()[source]
numRows()[source]
transpose()[source]
class parmed.unit.mymatrix.MyVector(collection)[source]

Bases: object

Parent class of MyMatrix and type of Matrix Row.

parmed.unit.mymatrix.eye(size)[source]

Returns identity matrix.

>>> print(eye(3))
[[1, 0, 0]
 [0, 1, 0]
 [0, 0, 1]]
parmed.unit.mymatrix.zeros(m, n=None)[source]

Returns matrix of zeroes

>>> print(zeros(3))
[[0, 0, 0]
 [0, 0, 0]
 [0, 0, 0]]