سؤال

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top