Commit 736c2038 authored by eric pellegrini's avatar eric pellegrini
Browse files

removed remaining Scientific.LA deps

Removed dead code
parent 7d782196
......@@ -17,7 +17,6 @@ import numpy
from Scientific.Geometry import Vector
# Error type
class GeomError(Exception):
pass
......@@ -789,8 +788,8 @@ def superpositionFit(confs):
k = 2.*k
for i in range(4):
k[i, i] = k[i, i] + possq - numpy.add.reduce(pos*pos)
from Scientific import LA
e, v = LA.eigenvectors(k)
e, v = numpy.linalg.eig(k)
v = numpy.transpose(v)
i = numpy.argmin(e)
v = v[i]
if v[0] < 0: v = -v
......
......@@ -5,65 +5,23 @@
__docformat__ = 'restructuredtext'
import numpy
from MMTK import Units, ParticleProperties, Visualization
import copy
#
# Import LAPACK routines or equivalents
#
import numpy
eigh = None
from MMTK import ParticleProperties, Visualization
# Use symeig (http://mdp-toolkit.sourceforge.net/symeig.html)
# if it is installed and if NumPy is used (symeig works only
# with NumPy). Symeig uses the LAPACK routine dsyevr, which
# uses less memory than dsyevd. It is also said to be faster,
# but in my tests on the Mac it turned out to be slightly slower.
dgesdd = None
try:
from numpy.linalg import eigh
from numpy.linalg.lapack_lite import dgesdd
except ImportError:
pass
dsyevd = None
dgesdd = None
try:
from numpy.linalg.lapack_lite import dsyevd, dgesdd, LapackError
except ImportError: pass
if dsyevd is None:
try:
# PyLAPACK
from lapack_dsy import dsyevd, LapackError
except ImportError: pass
if dgesdd is None:
try:
# PyLAPACK
from lapack_dge import dgesdd
except ImportError: pass
if dsyevd is None:
from numpy.linalg import eigh
if dsyevd:
n = 1
array = numpy.zeros((n, n), numpy.float)
ev = numpy.zeros((n,), numpy.float)
work = numpy.zeros((1,), numpy.float)
int_types = [numpy.int, numpy.int8, numpy.int16, numpy.int32]
try:
int_types.append(numpy.int64)
int_types.append(numpy.int128)
except AttributeError:
pass
for int_type in int_types:
iwork = numpy.zeros((1,), int_type)
try:
dsyevd('V', 'L', n, array, n, ev, work, -1, iwork, -1, 0)
break
except LapackError:
pass
del n, array, ev, work, iwork, int_types
del array_package
#
# Class for a single mode
......@@ -251,32 +209,13 @@ class NormalModes(object):
return eigenvalues
# Calculate eigenvalues and eigenvectors of self.array
if eigh is not None:
_symmetrize(self.array)
ev, modes = eigh(self.array, overwrite_a=True)
self.array = numpy.transpose(modes)
elif dsyevd is None:
ev, modes = Heigenvectors(self.array)
ev = ev.real
modes = modes.real
self.array = modes.T
else:
ev = numpy.zeros((self.nmodes,), numpy.float)
work = numpy.zeros((1,), numpy.float)
iwork = numpy.zeros((1,), int_type)
results = dsyevd('V', 'L', self.nmodes, self.array, self.nmodes,
ev, work, -1, iwork, -1, 0)
lwork = int(work[0])
liwork = iwork[0]
work = numpy.zeros((lwork,), numpy.float)
iwork = numpy.zeros((liwork,), int_type)
results = dsyevd('V', 'L', self.nmodes, self.array, self.nmodes,
ev, work, lwork, iwork, liwork, 0)
if results['info'] > 0:
raise ValueError('Eigenvalue calculation did not converge')
_symmetrize(self.array)
ev, modes = numpy.linalg.eigh(self.array, overwrite_a=True)
self.array = numpy.transpose(modes)
if self.basis is not None:
self.array = numpy.dot(self.array, self.basis)
return ev
def _setupBasis(self):
......
......@@ -11,7 +11,7 @@ __docformat__ = 'restructuredtext'
import numpy
from MMTK import Collections, Units, Universe, Utility, \
from MMTK import Collections, Units, Utility, \
ParticleProperties, Visualization
from Scientific.Geometry import Vector
import copy, os, sys
......@@ -935,10 +935,9 @@ class RigidBodyTrajectory(object):
quaternions = numpy.zeros((steps, 4), numpy.float)
fit = numpy.zeros((steps,), numpy.float)
from numpy.linalg import eig
for i in range(steps):
e, v = eig(k[i])
v = v.T
e, v = numpy.linalg.eig(k[i])
v = numpy.transpose(v)
j = numpy.argmin(e)
if e[j] < 0.:
fit[i] = 0.
......
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