/usr/lib/python2.7/dist-packages/pysparse/sparseMatrix.py is in python-sparse 1.1-1.2build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | #! /usr/bin/python
## -*-Pyth-*-
# ###################################################################
# FiPy - Python-based finite volume PDE solver
#
# FILE: "sparseMatrix.py"
# created: 11/10/03 {3:15:38 PM}
# last update: 1/3/07 {3:03:32 PM}
# Author: Jonathan Guyer <guyer@nist.gov>
# Author: Daniel Wheeler <daniel.wheeler@nist.gov>
# Author: James Warren <jwarren@nist.gov>
# Author: Maxsim Gibiansky <maxsim.gibiansky@nist.gov>
# mail: NIST
# www: http://www.ctcms.nist.gov/fipy/
#
# ========================================================================
# This software was developed at the National Institute of Standards
# and Technology by employees of the Federal Government in the course
# of their official duties. Pursuant to title 17 Section 105 of the
# United States Code this software is not subject to copyright
# protection and is in the public domain. FiPy is an experimental
# system. NIST assumes no responsibility whatsoever for its use by
# other parties, and makes no guarantees, expressed or implied, about
# its quality, reliability, or any other characteristic. We would
# appreciate acknowledgement if the software is used.
#
# This software can be redistributed and/or modified freely
# provided that any derivative works bear some notice that they are
# derived from it, and any modified versions bear some notice that
# they have been modified.
# ========================================================================
#
# Description:
#
# History
#
# modified by rev reason
# ---------- --- --- -----------
# 2003-11-10 JEG 1.0 original
# 2006-06-12 MLG 1.0 made abstract
# ###################################################################
##
__docformat__ = 'restructuredtext'
import numpy
class SparseMatrix:
"""
.. attention:: This class is abstract. Always create one of its subclasses.
"""
def __init__(self, size=None, bandwidth=0, matrix=None, sizeHint=None):
pass
__array_priority__ = 100.0
def getMatrix(self):
pass
def __array_wrap(self, arr, context=None):
if context is None:
return arr
else:
return NotImplemented
def copy(self):
pass
def __getitem__(self, index):
pass
def __str__(self):
s = ""
cellWidth = 11
shape = self.getShape()
for i in range(shape[0]):
for j in range(shape[1]):
v = self[i,j]
if v == 0:
s += "---".center(cellWidth)
else:
exp = numpy.log(abs(v))
if abs(exp) <= 4:
if exp < 0:
s += ("%9.6f" % v).ljust(cellWidth)
else:
s += ("%9.*f" % (6,v)).ljust(cellWidth)
else:
s += ("%9.2e" % v).ljust(cellWidth)
s += "\n"
return s[:-1]
def __repr__(self):
return repr(self.matrix)
def __setitem__(self, index, value):
pass
def __add__(self, other):
pass
__radd__ = __add__
def __iadd__(self, other):
pass
def __sub__(self, other):
pass
# Ask about this rsub
def __rsub__(self, other):
return -(__sub__(self, other))
def __isub__(self, other):
pass
def __mul__(self, other):
pass
def __rmul__(self, other):
pass
def __neg__(self):
return self * -1
def __pos__(self):
return self
## def __eq__(self,other):
## return self.matrix.__eq__(other._getMatrix())
def getShape(self):
pass
## def transpose(self):
## pass
def put(self, vector, id1, id2):
pass
def putDiagonal(self, vector):
pass
def take(self, id1, id2):
pass
def takeDiagonal(self):
pass
def addAt(self, vector, id1, id2):
pass
def addAtDiagonal(self, vector):
pass
def getNumpyArray(self):
pass
def exportMmf(self, filename):
pass
## def __array__(self):
## shape = self._getShape()
## indices = numpy.indices(shape)
## numMatrix = self.take(indices[0].ravel(), indices[1].ravel())
## return numpy.reshape(numMatrix, shape)
|