0

I am trying to get EJML to work, especially to create matrices with random numbers. Creating regular a SimpleMatrix and DMatrixRMaj works well. But I keep getting java.lang.RuntimeException: Uncompilable code - cannot find symbol when using more advanced statements such as

DMatrixRMaj D2 = new RandomMatrices_DDRM.createSymmetric(20,-2,3,rand);

or

SimpleMatrix S2 = new SimpleMatrix.random64(20,20,-2,3,rand);

Below is the full code and error messages.

Thanks!

/Benny

package com.benny.evosim;

import java.util.*;

import org.ejml.simple.SimpleMatrix;

import org.ejml.data.DMatrixRMaj;

import org.ejml.dense.row.RandomMatrices_DDRM;

public class EvoSim {

public static void main(String[] args) {

    EvoSim evoSimInstance = new EvoSim();
    evoSimInstance.start();
}

public void start() {
    
    Random rand = new Random();
    SimpleMatrix A = new SimpleMatrix(3,3);
    DMatrixRMaj​ D  = new DMatrixRMaj(3,3) ; 
    
    DMatrixRMaj D2 = new RandomMatrices_DDRM.createSymmetric(20,-2,3,rand);
    SimpleMatrix S2 = new SimpleMatrix.random64(20,20,-2,3,rand);
    
    A.print();
    }
}

ERROR MESSAGE

--------------------------< com.benny:evosim >--------------------------
Building evosim 1.0-SNAPSHOT
--------------------------------[ jar ]---------------------------------

--- exec-maven-plugin:3.0.0:exec (default-cli) @ evosim ---
Exception in thread "main" java.lang.RuntimeException: Uncompilable code - cannot find symbol
  symbol:   variable RandomMatrices_DDRM
  location: class com.benny.evosim.EvoSim
    at com.benny.evosim.EvoSim.start(EvoSim.java:1)
    at com.benny.evosim.EvoSim.main(EvoSim.java:26)
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)

1 Answers1

1

Use the static symmetric method in RandomMatrices_DDRM

DMatrixRMaj d2 = RandomMatrices_DDRM.symmetric(20,-2,3,rand);

and similarly for SimpleMatrix

Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • Thank you for the reply. I tried to add the parenthesis as in your example but still get the same error for the first one (DMatrixRMaj) and for the SimpleMatrix it crashes even earlier unless I specify the same dimension, like ´SimpleMatrix S2 = new SimpleMatrix(20,20).random64(20,20,-2,3,rand);´, still end up with the same problem though. Using code from official site: https://ejml.org/wiki/index.php?title=Random_matrices,_Matrix_Features,_and_Matrix_Norms – johansson.benny Apr 22 '22 at 21:41
  • From the [javadoc](http://ejml.org/javadoc/org/ejml/simple/SimpleMatrix.html) there's no `random64` method but there is a `random_DDRM​` with those arguments – Reimeus Apr 23 '22 at 00:08
  • Thanks, the following line worked well: ´SimpleMatrix S2 = SimpleMatrix.random_DDRM(3,3,0,1,rand);´ – johansson.benny Apr 23 '22 at 07:27
  • FYI creating an instance of RandomMatrices_DDRM isn't required. All it's member functions are static. – lessthanoptimal Dec 31 '22 at 17:18
  • @lessthanoptimal code corrected :) – Reimeus Jan 03 '23 at 10:15