Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
if not os.path.isfile(self.filename):
raise Exception('%s not found' % self.filename)
if as_sparse:
try:
from scipy.sparse import csc_matrix, coo_matrix
except ImportError:
raise ImportError('Unable to load scipy, use ``load_km`` with '
'``as_sparse=False``')
# Get header details
neqn = self._header['neqn'] # Number of equations
# number of terms in stiffness matrix
ntermK = two_ints_to_long(self._header['ntermKl'], self._header['ntermKh'])
ptrSTF = self._header['ptrSTF'] # Location of stiffness matrix
ptrMAS = self._header['ptrMAS'] # Location in file to mass matrix
# number of terms in mass matrix
ntermM = two_ints_to_long(self._header['ntermMl'], self._header['ntermMh'])
ptrDOF = self._header['ptrDOF'] # pointer to DOF info
# DOF information
with open(self.filename, 'rb') as f:
read_table(f, skip=True) # standard header
read_table(f, skip=True) # full header
read_table(f, skip=True) # number of degrees of freedom
# Nodal equivalence table
neqv = read_table(f, cython=True)
from scipy.sparse import csc_matrix, coo_matrix
except ImportError:
raise ImportError('Unable to load scipy, use ``load_km`` with '
'``as_sparse=False``')
# Get header details
neqn = self._header['neqn'] # Number of equations
# number of terms in stiffness matrix
ntermK = two_ints_to_long(self._header['ntermKl'], self._header['ntermKh'])
ptrSTF = self._header['ptrSTF'] # Location of stiffness matrix
ptrMAS = self._header['ptrMAS'] # Location in file to mass matrix
# number of terms in mass matrix
ntermM = two_ints_to_long(self._header['ntermMl'], self._header['ntermMh'])
ptrDOF = self._header['ptrDOF'] # pointer to DOF info
# DOF information
with open(self.filename, 'rb') as f:
read_table(f, skip=True) # standard header
read_table(f, skip=True) # full header
read_table(f, skip=True) # number of degrees of freedom
# Nodal equivalence table
neqv = read_table(f, cython=True)
# read number of degrees of freedom for each node and constant tables
f.seek(ptrDOF*4)
ndof = read_table(f, cython=True)
const = read_table(f, cython=True)