Exemple #1
0
    def test_apply_rowwise(self):
        A = elem.DistMatrix_d_VR_STAR()
        elem.Uniform(A, 100, self.n)

        S  = sketch.FJLT(self.n, self.sn)
        SA = np.zeros((100, self.sn), order='F')
        S.apply(A, SA, "rowwise")
Exemple #2
0
    def test_apply_colwise(self):
        A = elem.DistMatrix_d_VR_STAR()
        elem.Uniform(A, self.n, 100)

        S  = sketch.FJLT(self.n, self.sn)
        SA = np.zeros((self.sn, 100), order='F')
        S.apply(A, SA, "columnwise")
Exemple #3
0
    def test_apply_colwise(self):
        A = elem.DistMatrix_d_VR_STAR()

        #FIXME: Christos, use your matrix problem factory here
        elem.Uniform(A, _M, _N)

        #FIXME: A.Matrix will not work in parallel
        self.sv  = np.linalg.svd(A.Matrix, full_matrices=1, compute_uv=0)

        for sketch in self.sketches:
            results = test_helper(A, _M, _N, _R, sketch, [self.svd_bound], MPI)
            self.check_result(results, str(sketch))
Exemple #4
0
def _usage_tests(usps_path='./datasets/usps.t'):
    '''
    Various simple example scenaria for showing the usage of the IO facilities
    '''

    ############################################################
    # libsvm
    ############################################################
    fpath = usps_path

    # read features matrix and labels vector
    try:
        store = libsvm(fpath)
    except ImportError:
        print 'Please provide the path to usps.t as an argument'
        import sys; sys.exit()
    features_matrix, labels_matrix = store.read()
    matrix_info = features_matrix.shape, features_matrix.nnz, labels_matrix.shape

    # stream features matrix and labels vector
    store = libsvm(fpath)
    for features_matrix, labels_matrix in store.stream(num_features=400, block_size=100):
        matrix_info = features_matrix.shape, features_matrix.nnz, labels_matrix.shape
    print 'libsvm OK'

    ############################################################
    # mtx
    ############################################################
    features_fpath = '/tmp/test_features.mtx'
    labels_fpath   = '/tmp/test_labels.mtx'

    # write features and labels
    store = mtx(features_fpath)
    store.write(features_matrix)
    store = mtx(labels_fpath)
    store.write(labels_matrix)

    # read back features as 'scipy-sparse' and 'combblas-sparse'
    store = mtx(features_fpath)
    A = store.read('scipy-sparse')
    store = mtx(features_fpath)
    B = store.read('combblas-sparse')
    print 'mtx OK'

    ############################################################
    # hdf5
    ############################################################
    fpath = '/tmp/test_matrix.h5'

    # write a random 'numpy-dense' to HDF5 file
    store = hdf5(fpath)
    A = numpy.random.random((20, 65))
    store.write(A)

    # read HDF5 file as:
    # - 'numpy-dense'
    # - 'elemental-dense' (default 'MC_MR' distribution)
    # - 'elemental-dense' ('VC_STAR' distribution)
    B = store.read('numpy-dense')
    C = store.read('elemental-dense')
    D = store.read('elemental-dense', distribution='VC_STAR')
    print 'hdf OK'

    ############################################################
    # txt
    ############################################################
    fpath = '/tmp/test_matrix.txt'

    # write a uniform random 'elemental-dense', 'MC_MR' distribution
    A = elem.DistMatrix_d()
    elem.Uniform(A, 10, 30)
    store = txt(fpath)
    store.write(A)

    # read the matrix back as 'numpy-dense'
    store = txt(fpath)
    A = store.read('numpy-dense')
    print 'txt OK'
Exemple #5
0
import elem
from skylark import sketch, elemhelper
from mpi4py import MPI
import numpy as np
import time

# Configuration
m = 20000
n = 300
t = 1000
#sketches = { "JLT" : sketch.JLT, "FJLT" : sketch.FJLT, "CWT" : sketch.CWT }
sketches = {"JLT": sketch.JLT, "CWT": sketch.CWT}

# Set up the random regression problem.
A = elem.DistMatrix_d_VR_STAR()
elem.Uniform(A, m, n)
b = elem.DistMatrix_d_VR_STAR()
elem.Uniform(b, m, 1)

# Solve using Elemental
# Elemental currently does not support LS on VR,STAR.
# So we copy.
A1 = elem.DistMatrix_d()
elem.Copy(A, A1)
b1 = elem.DistMatrix_d()
elem.Copy(b, b1)
x = elem.DistMatrix_d(n, 1)
t0 = time.time()
elem.LeastSquares(elem.NORMAL, A1, b1, x)
telp = time.time() - t0