Generate Matrix

14 views
Skip to first unread message

aran nokan

unread,
Nov 30, 2020, 12:55:08 PM11/30/20
to MAGMA User
I want to generate a matrix by inspiration of what I am seeing in testing directory, but it is not clear for me. Could you please give me some hints?

Just I want to send first dimension from user to opts, but I dont know how it is working.

void init_matrix(
                magma_opts &opts,
                magma_int_t m, magma_int_t n,
                double *A, magma_int_t lda )
{
        magma_int_t iseed_save[4];
        for (magma_int_t i = 0; i < 4; ++i) {
                iseed_save[i] = opts.iseed[i];
        }  

        magma_generate_matrix( opts, m, n, A, lda );

        // restore iseed
        for (magma_int_t i = 0; i < 4; ++i) {
                opts.iseed[i] = iseed_save[i];
        }  
}

Mark Gates

unread,
Dec 2, 2020, 4:25:03 PM12/2/20
to aran nokan, MAGMA User
The magma_opts class and the magma_generate_matrix are fairly specific to the MAGMA testing environment. That is, they weren't designed for general use outside MAGMA's testers. You are free to use and adapt them for use outside, just know that's the limitation.

If you grep for use of opts in magma_generate.cpp, you will see what fields in opts are used and therefore need to be set. For instance, opts.iseed, verbose, matrix, cond, condD are used in various places.

magma/testing> grep 'opts\.' magma_generate.cpp 

            lapack::larnv( idist_rand, opts.iseed, sigma.n, sigma(0) );

            lapack::larnv( idist, opts.iseed, sigma.n, sigma(0) );

    lapack::larnv( idist_randn, opts.iseed, sizeU, U(0,0) );

    lapack::larnv( idist_randn, opts.iseed, sizeU, U(0,0) );

        lapack::larnv( idist_rand, opts.iseed, D.n, D(0) );

        if (opts.verbose) {

    lapack::larnv( idist_randn, opts.iseed, sizeU, U(0,0) );

        lapack::larnv( idist_rand, opts.iseed, n, D(0) );

    std::string name = opts.matrix;

    real_t cond = opts.cond;

    real_t condD = opts.condD;

    if (opts.cond != 0

                 ansi_red, name.c_str(), opts.cond, ansi_normal );

    if (opts.cond != 0

                 ansi_red, name.c_str(), opts.cond, ansi_normal );

            lapack::larnv( idist, opts.iseed, sizeA, A(0,0) );


See the documentation of magma_generate_matrix for specifics about what those fields mean.

The dimensions (m, n) are passed separately, not in opts.

Mark
Reply all
Reply to author
Forward
0 new messages