Example #1
0
 def __save_and_load_test (self, name, A ):
     save_scipy_matrix_as_mat ( data_path, name, A )
     A_load = load_scipy_matrix_from_mat ( data_path, name )
     
     np.testing.assert_equal ( A_load.shape, A.shape )
     
     if type(A) != np.ndarray:
         np.testing.assert_equal( A_load.data, A.data ) 
         np.testing.assert_equal( A_load.indices, A.indices )
         np.testing.assert_equal( A_load.indptr, A.indptr )
     else:
         np.testing.assert_equal( A_load, A )
Example #2
0
    def __save_and_load_test(self, name, A):
        save_scipy_matrix_as_mat(data_path, name, A)
        A_load = load_scipy_matrix_from_mat(data_path, name)

        np.testing.assert_equal(A_load.shape, A.shape)

        if type(A) != np.ndarray:
            np.testing.assert_equal(A_load.data, A.data)
            np.testing.assert_equal(A_load.indices, A.indices)
            np.testing.assert_equal(A_load.indptr, A.indptr)
        else:
            np.testing.assert_equal(A_load, A)
Example #3
0
def save_matrices(path, id, A, b):
    """
    Save the system matrix and the excitation vector.
    The matrices will be saved in <path>/<id>/A.mat and <path>/<id>/b.mat
    
    @param path: the folder where the matrices are to be saved
    @param id: a unique problem identifier
    @param A: the system matrix
    @param b: the excitation vector
    """
    full_path = os.path.join(path, id)

    save_scipy_matrix_as_mat(full_path, 'A', A)
    save_scipy_matrix_as_mat(full_path, 'b', b)

    dofs = A.shape[0]
    f = file(os.path.join(full_path, '%dDOFs.txt' % dofs), 'w')
    f.write('DOFs = %d\n' % dofs)
    f.close()
Example #4
0
 def test_save_scipy_matrix ( self ):
     import scipy.sparse
     N = 1000;
     A = scipy.sparse.rand ( N, N, format='csr' )
     
     save_scipy_matrix_as_mat ( data_path, 'A', A )
Example #5
0
    def test_save_scipy_matrix(self):
        import scipy.sparse
        N = 1000
        A = scipy.sparse.rand(N, N, format='csr')

        save_scipy_matrix_as_mat(data_path, 'A', A)