* @brief Initialize the model randomly with a user-provided scale factor */
| 41 | * @brief Initialize the model randomly with a user-provided scale factor |
| 42 | */ |
| 43 | void initialize(const double &inScaleFactor) { |
| 44 | // using madlib::dbconnector::$database::NativeRandomNumberGenerator |
| 45 | NativeRandomNumberGenerator rng; |
| 46 | int i, j, rr; |
| 47 | double base = rng.min(); |
| 48 | double span = rng.max() - base; |
| 49 | for (rr = 0; rr < matrixU.cols(); rr ++) { |
| 50 | for (i = 0; i < matrixU.rows(); i ++) { |
| 51 | matrixU(i, rr) = inScaleFactor * (rng() - base) / span; |
| 52 | } |
| 53 | } |
| 54 | for (rr = 0; rr < matrixV.cols(); rr ++) { |
| 55 | for (j = 0; j < matrixV.rows(); j ++) { |
| 56 | matrixV(j, rr) = inScaleFactor * (rng() - base) / span; |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /* |
| 62 | * Some operator wrappers for two matrices. |
no test coverage detected