简体   繁体   中英

CUSP function to generate a matrix with random values

I was wondering if CUSP library provides a function that creates a matrix with a specific number of columns, rows, and any random values?

I found poisson5pt function but it doesn't return back a matrix with the dimensions I specify!

Thanks in advance

In the CUSP matrix gallery you will find random.h which almost does what you want:

template <class MatrixType>
void random(size_t num_rows, size_t num_cols, size_t num_samples, MatrixType& output)

This will produce a matrix of the dimensions you specify with the number of random locations you request filled with 1.

It would be trivial to modify that to use a random value rather than unity, although I don't understand why you would ever want such a matrix. It will not be guaranteed to have any of the properties you probably need in a test matrix if you have plans to use such a matrix in any linear algebra operations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM