Code Monkey home page Code Monkey logo

efficient-java-matrix-library's People

Watchers

 avatar

efficient-java-matrix-library's Issues

Nullity() and nullspace()

What steps will reproduce the problem?
1. Compute the SVD of matrix [ 1 0 0 ]
2. Nullity()


What is the expected output? What do you see instead?
Nullity = 0 . Expected output  = 2.
Verified using wolfram alpha with input nullity {{1,0,0}}

What version of the product are you using? On what operating system?
Linux.

Please provide any additional information below.
The rank is one , so I think nullspace() should be 3*2 matrix , but I only get 
a 3*1 matrix.


Original issue reported on code.google.com by [email protected] on 9 May 2012 at 2:01

Accuracy loss

Hi!
I'am using EJML for my numerical optimization software. I think there is some 
problem with accuracy in calculations (i.e. innerProduct)

What steps will reproduce the problem?

public class PrecisionTest
{
  public static void main(String[] arg0)
  {
    int testCount= 10;

    for(int testIndex=0; testIndex<testCount; testIndex++) 
    {
      double s1= 0.0, s2= 0.0;

      double[] p1= new double[50], p2= new double[50];

      Arrays.fill(p1,Math.PI); Arrays.fill(p2,Math.PI);

      for(int testRepeat=0; testRepeat<10000; testRepeat++)
      {
    for(int i=0; i<50; i++)
    {
      s2 += p1[i]*p2[i];
    }
      }


      DenseMatrix64F v1= new DenseMatrix64F(1,50,true,p1), v2= new DenseMatrix64F(50,1,false,p2);

      for(int testRepeat=0; testRepeat<10000; testRepeat++)
      {
    s1 += VectorVectorMult.innerProd(v1, v2);
      }

      System.out.println("s1="+String.format("%.25f",s1)
                         +",s2="+String.format("%.25f",s2)
                         +",s1-s2="+String.format("%.25f",s1-s2));
    }
  }
}

What is the expected output? What do you see instead?

Expected Abs(s1-s2)= 0.0, but realy Abs(s1-s2) > 0.0. ??? please check the loss 
of accuracy in calculations. I'll be happy to be wrong in its conclusions.

What version of the product are you using? On what operating system?

EJML-0.18.jar, source: maven repo.

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 12 Feb 2012 at 8:33

Large Memory requirement

My project is  http://code.google.com/p/jmatrix/

I am working with a large matrix 500MB-1GB. Your ejml is much faster than JAMA 
when doing eigenvalue decomposition. However, JAMA uses the given matrix as 
working area. EJML asks for more memory, which I do not have on my laptop. 

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
Version 0.17, 2011 February 23
Windows-7

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 31 Jul 2012 at 10:27

LinearSolverChol::solve(B,X) - obvious BUG in dimensions check

in LinearSolverChol.java:78:

if( B.numCols != X.numCols && B.numRows != n && X.numRows != n) {
            throw new IllegalArgumentException("Unexpected matrix size");
}

obviosuly, must be:
if( B.numCols != X.numCols || B.numRows != n || X.numRows != n) {
...

otherwise, the exception is thrown only if ALL preconditions fail.



Original issue reported on code.google.com by [email protected] on 26 Apr 2014 at 11:18

There's problem at Big matrix

Hi, Thanks for great library.

I've tried to make 49000 x 49000 matrix, but there's problem. 
(Also, I should make 49000 x 130000 matrix, but didn't succeed)

Sometimes there's OutOfMemoryError, and sometimes 
NegativeArraySizeException(Don't know why negative exception caused integer 
type in Java support very big number)

Is there any limit in matrix?

Thanks in advance!


Original issue reported on code.google.com by [email protected] on 16 Sep 2013 at 2:04

Are eigenvalues sorted, largest to smallest?

Are the eigenvectors supposed to be sorted by eigenvalue, largest to smallest?  
When I try the eigen decomposition, it seems like the results are almost, but 
not quite, sorted.

Here is my test code:

public class EigTest {
    public static void main(String[] argv) {
        Random gen = new Random();

        int dim = 10;
        double[][] covArray = new double[dim][dim];
        for (int i1=0; i1<dim; i1++) {
            for (int i2=0; i2<=i1; i2++) {
                if (i1 == i2) {
                    covArray[i1][i2] = 1.0;
                }
                else{
                    covArray[i1][i2] = covArray[i2][i1] = 0.2 + 0.1*gen.nextDouble();
                }
            }
        }
        SimpleMatrix covMatrix = new SimpleMatrix(covArray);
        EVD evd = covMatrix.eig();
        for (int i=0; i<dim; i++) {
            System.out.println(i + " " + evd.getEigenvalue(i).getReal());
        }
    }
}


And here is the output:

0 3.199776985529203
1 0.6475744701287464
2 0.6179173072801434
3 0.6844364727875633
4 0.7209547852654137
5 0.7710224772493918
6 0.8081055762745701
7 0.8227425106373765
8 0.8738689128927779
9 0.8536005019548158



Original issue reported on code.google.com by [email protected] on 24 Feb 2011 at 7:10

support for 2d convolutions

I'm requesting a new feature be added to EJML to perform 2d matrix convolutions 
similar to the octave function conv2.  For example, in octave, given a 'data' 
matrix and a 'feature' matrix, you'd execute the following:

    feature = flipud(fliplr(squeeze(feature)));
    convolved_data = conv2(data, feature, "valid");

The slow element-wise algorithm would be:


  convolved_data = zeros(size(data,1) - size(feature,1) + 1, size(data,2) - size(feature,2) + 1);

  for iy = size(convolved_data,2)
    for ix = 1:size(convolved_data,1)
      for fy = 1:size(feature,2)
        for fx = 1:size(feature,1)
          convolved_data(ix, iy) += data(ix+fx-1,iy+fy-1) * feature(fx, fy);
        endfor
      endfor
    endfor
  endfor

Original issue reported on code.google.com by [email protected] on 15 Sep 2012 at 4:26

Very small numbers can cause a divided by zero error in SVD

When decomposing a matrix with elements that are very small there are 
situations where this can cause a divided by zero error.  A potential fix has 
been committed that changes the way exceptional shifts, wilkinson step, and 
other parts of the code are handled.  Also more checks are in place for zeros.

The fix is current being verified.

Original issue reported on code.google.com by [email protected] on 2 Jul 2010 at 5:08

Remove awt/swing dependancies from data/* for Android

I've been using ejml on Android which has no swing/awt implementation.  I 
specifically need the data/* classes.  The following patch removes 
dependanceies of data/* classes on swing/awt.  One of the main consequences of 
this patch is to remove the JFrame output from MatrixIO.  For my use-case, this 
is necessary.

This patch is not as nice as you might want for integration.  Should you be 
interested in this feature (i.e. Android "compatability") then I'll happily 
clean up this patch against the latest svn HEAD.

[aidan@SillyFace spidersketch]$ git diff
diff --git a/src/org/ejml/data/D1Submatrix64F.java 
b/src/org/ejml/data/D1Submatrix64F.java
index ebdf8b4..e85a891 100644
--- a/src/org/ejml/data/D1Submatrix64F.java
+++ b/src/org/ejml/data/D1Submatrix64F.java
@@ -19,7 +19,7 @@

 package org.ejml.data;

-import java.awt.*;
+//import java.awt.*;


 /**
diff --git a/src/org/ejml/data/SimpleMatrix.java 
b/src/org/ejml/data/SimpleMatrix.java
index fc098fb..9f6e07e 100644
--- a/src/org/ejml/data/SimpleMatrix.java
+++ b/src/org/ejml/data/SimpleMatrix.java
@@ -24,7 +24,13 @@ import org.ejml.alg.dense.decomposition.DecompositionFactory;
 import org.ejml.alg.dense.decomposition.EigenDecomposition;
 import org.ejml.alg.dense.decomposition.SingularMatrixException;
 import org.ejml.alg.dense.decomposition.SingularValueDecomposition;
-import org.ejml.ops.*;
+import org.ejml.ops.CommonOps;
+import org.ejml.ops.SingularOps;
+import org.ejml.ops.SpecializedOps;
+import org.ejml.ops.NormOps;
+import org.ejml.ops.MatrixIO;
+import org.ejml.ops.RandomMatrices;
+import org.ejml.ops.MatrixFeatures;

 import java.io.IOException;
 import java.util.Random;
diff --git a/src/org/ejml/ops/MatrixIO.java b/src/org/ejml/ops/MatrixIO.java
index 597089e..1446c91 100644
--- a/src/org/ejml/ops/MatrixIO.java
+++ b/src/org/ejml/ops/MatrixIO.java
@@ -22,8 +22,8 @@ package org.ejml.ops;
 import org.ejml.data.D1Matrix64F;
 import org.ejml.data.Matrix64F;

-import javax.swing.*;
-import java.awt.*;
+//import javax.swing.*;
+//import java.awt.*;
 import java.io.*;


@@ -42,7 +42,7 @@ public class MatrixIO {
      * @param A A matrix.
      * @param title Name of the window.
      */
-    public static void show( D1Matrix64F A , String title ) {
+    /*    public static void show( D1Matrix64F A , String title ) {
         JFrame frame = new JFrame(title);

         int width = 300;
@@ -62,7 +62,7 @@ public class MatrixIO {
         frame.pack();
         frame.setVisible(true);

-    }
+       }*/

     /**
      * Saves a matrix to disk using Java binary serialization.

Original issue reported on code.google.com by [email protected] on 13 Mar 2011 at 4:03

Bad eigenvector in general matrices when repeat eigenvalues are present

Unit test fails.  This error does not affect symmetric matrix algorithm. 
In practice this error will not affect many people since eigenvalues are
typically only computed for symmetric matrices.  Non-symmetric matrices
require complex numbers, which are only minimally supported in EJML.

Original issue reported on code.google.com by [email protected] on 17 Feb 2010 at 3:26

Searching for org.ejml.simple

I have used import org.ejml.simple.*.*; to import EJML to my processing sketch. 
The path is well-defined and yet
the compiler says it cannot find the code. Am I missing another download?

Thank you.

John Sevic

Original issue reported on code.google.com by [email protected] on 10 Jun 2014 at 10:13

Attachments:

Add row and column methods to CommonOps

Although easy to implement, it would be of convenience to have methods in 
CommonOps that return a vector with either the row totals or the column totals 
of a Matrix.

Original issue reported on code.google.com by [email protected] on 30 May 2011 at 12:14

LinearSolver (symmPosDef) doesn't appear to work at all.

What steps will reproduce the problem?
1.

see attached java file
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
0.24

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 9 Apr 2014 at 10:08

Attachments:

possible problem with solve with larger dimensions

What steps will reproduce the problem?

private static void initRandom(DenseMatrix64F m) {
  for(int i = 0; i < m.numRows; i++) {
    for(int j = 0; j < m.numCols; j++) {
      m.set(i, j, Math.random());
    }
  }
}

private static void sTest(int r, int c) {
  System.out.println("sTest r: " + r + " c: " + c);
  DenseMatrix64F A = new DenseMatrix64F(r, c);
  DenseMatrix64F x = new DenseMatrix64F(c, 1);
  DenseMatrix64F b = new DenseMatrix64F(r, 1);
  initRandom(A);
  initRandom(b);
  CommonOps.solve(A, b, x);
}

sTest(3, 2); // fine
sTest(2, 401); // throws exception

What is the expected output? What do you see instead?

Should solve, instead throws exception


What version of the product are you using? On what operating system?

0.21, Windows


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 1 Jul 2014 at 6:08

Add complex eigenvectors

See if this can be done without doing a complete complex decomposition.  Sounds 
like it might be possible

Original issue reported on code.google.com by [email protected] on 26 Feb 2014 at 11:33

SolvePseudoInverse invert method returns zero

What steps will reproduce the problem?
1. SolvePseudoInverse pinv = new SolvePseudoInverse();
2. pinv.setA(any input DenseMatrix64F);
3. pinv.invert(any output DenseMatrix64F);

What is the expected output? What do you see instead?
Expected: pseudo-inverse of the input matrix.
Obtained: zero matrix.

What version of the product are you using? On what operating system?
v0.17, Windows 7 64 bits

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 27 Oct 2011 at 6:47

Add support for matrices with zero dimensions

It would be nice if EJML were able to handle matrices with zero dimensions.

Example:
A is 6 x 0
B = 0 x 6

A * B should result in a matrix of dimension 6 x 6 containing all zeros
B * A should result in a matrix of dimension 0 x 0

Matlab is able to handle this kind of thing:
>> A = zeros(6, 0);
>> B = zeros(0, 6);
>> A * B
ans =
     0     0     0     0     0     0
     0     0     0     0     0     0
     0     0     0     0     0     0
     0     0     0     0     0     0
     0     0     0     0     0     0
     0     0     0     0     0     0

>> B * A
ans =
     []

>> size(B * A)

ans =
     0     0

This saves a lot of if statements when sizes of matrices happen to be zero.

Original issue reported on code.google.com by [email protected] on 29 Apr 2013 at 8:01

make 32bit float (float) versions of all matrices

I have an application that runs on an embedded device, for performance reasons 
I would like to use 32bit float instead of double.

I also have to use several other libraries that only accept 32bit float. 
Iterating over a matrix data array and casting each 64bit float to 32bit float 
is hurting performance.

Is it possible to create an 32bit float matrix & operations?


Original issue reported on code.google.com by [email protected] on 13 Jun 2014 at 1:48

applying SVD on very large matrices causes a memory exception

Matrix size is 7000x60000
The matrix is initialized and filled with large number of different values. 
When I try to apply the SVD function on the marix, I get the following:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Program is set to use 7GB of memory with the following:
-Xmx7000m -Xms4600m

This is the line causing the trouble in my program:
SingularValueDecomposition svd = SpecializedOps.svd(TrainM);


Any hints or workarounds to make this work ?

Original issue reported on code.google.com by [email protected] on 7 Dec 2009 at 11:37

SimpleMatrix invert: no exception for singular matrix

When trying to invert a Singular Matrix using SimpleMatrix interface, an 
IlegalArgumentException is expected, but not thrown.

Code snippet:
SimpleMatrix m = new SimpleMatrix(new double[][]{{1,2,3},{4,5,6},{7,8,9}});
System.out.println("det(m) = "+m.determinant());
m.invert();
System.out.println("An exception should have been thrown !");

Produces:
det(m) = 0.0
An exception should have been thrown !

Which is weird because SimpleMatrix#invert() seems to call 
CommonOps#invert(m,m_inv) which produces the expected behaviour when called 
directly...

I am using ejml v0.24


Original issue reported on code.google.com by [email protected] on 9 Jun 2014 at 7:42

MatrixFeatures.isPositiveDefinite() modifies matrix although JavaDoc states otherwise

What steps will reproduce the problem?
SimpleMatrix matrix = new SimpleMatrix(new double[][] { { 2, 0 }, { 0, 2 } });
matrix.print();
System.out.println("is pd? " + 
MatrixFeatures.isPositiveDefinite(matrix.getMatrix()));
matrix.print();

What is the expected output? What do you see instead?
Expected:
Type = dense , numRows = 2 , numCols = 2
 2,000   0,000  
 0,000   2,000  
is pd? true
Type = dense , numRows = 2 , numCols = 2
 2,000   0,000  
 0,000   2,000  

Actual:
Type = dense , numRows = 2 , numCols = 2
 2,000   0,000  
 0,000   2,000  
is pd? true
Type = dense , numRows = 2 , numCols = 2
 1,414   0,000  
 0,000   1,414  

What version of the product are you using? On what operating system?
EJML 0.21, Windows 7 Pro x64, Java 7u11 x64

Please provide any additional information below.
Maybe I misunderstand the description, but if I do, it's higly unintuitive 
nonetheless. I would expect an isXyz() method to not alter any parameters 
passed, esp. when it states so in the JavaDoc.

Original issue reported on code.google.com by [email protected] on 17 Jan 2013 at 8:41

Add support for NaN and Infinity when comparing matrices for equality.

What steps will reproduce the problem?
- Run the following code snippet:

        System.out.println(MatrixFeatures.isIdentical(
                new DenseMatrix64F(new double[][] {{ 1.0 }}),
                new DenseMatrix64F(new double[][] {{ Double.NaN }}),
                0.0)
        );

What is the expected output? What do you see instead?
- Observe that this prints "true", while it should actually print "false".


What version of the product are you using? On what operating system?
- EJML 0.15, Windows XP, JDK 1.6.0_21

Original issue reported on code.google.com by [email protected] on 23 Dec 2010 at 7:31

SingularOps.descendingOrder attempts to set a value out of bounds

What steps will reproduce the problem?
1. The attached serialized double[] is taken from DenseMatrix64F.getData(). The 
matrix is 832 x 10000. 
2. Load the matrix and then run the following code.

DenseMatrix64F m = ...;
SvdImplicitQrDecompose svd = new SvdImplicitQrDecompose(true);
svd.decompose(m);

final DenseMatrix64F u = svd.getU();
final DenseMatrix64F s = svd.getW(null);
final DenseMatrix64F v = svd.getV();

// This fails:  
SingularOps.descendingOrder(u, s, v);


3. SingularOps#descendingOrder will throw an exception:

java.lang.IllegalArgumentException: Specified element is out of bounds
    at org.ejml.data.DenseMatrix64F.set(DenseMatrix64F.java:224)
    at org.ejml.ops.SingularOps.descendingOrder(SingularOps.java:76)
    ...


What version of the product are you using? On what operating system?

Using release 0.12 from google code.


Other notes:

Great library. The only one I've used that can do an SVD of this size in < 4GB 
memory.



Original issue reported on code.google.com by [email protected] on 25 Jun 2010 at 5:25

Attachments:

Support for type byte arrays

Hi,

If I'm not mistaken, ejml support only double as the matrix data type. Is there 
a plan to support other type ? (I currently need byte to store RGB color 
matrix).

Thank you !

Original issue reported on code.google.com by [email protected] on 16 Mar 2012 at 6:05

Add RandomMatrix.setGaussian()

make it possible to fill a matrix with random draws from a Gaussian/Normal 
distribution.

Requested by Mikel Urquia Cortabarria

Original issue reported on code.google.com by [email protected] on 3 Oct 2014 at 12:55

MatrixIO.loadCSV() does not check the input data

Hello,

In the following code:

 try
            {
                numRows = Integer.parseInt(rowsJTextField.getText());
                numCols = Integer.parseInt(columnsJTextField.getText());
            } catch (NumberFormatException numberFormatException)
            {
                JOptionPane.showMessageDialog(rootPane, numberFormatException.getMessage(), "Problem with the conversion", JOptionPane.ERROR_MESSAGE);
            }
            try
            {
                dataset = MatrixIO.loadCSV(dataSetFileName, numRows, numCols);
            } catch (Exception ex)
            {
                JOptionPane.showMessageDialog(rootPane, ex.getMessage(), "I cannot load the file: " + datasetFile.getName(), JOptionPane.ERROR_MESSAGE);
                return;
            }

If I enter number of rows greater than the number that the file actually 
contains then the ex.getMessage() returns null.
If instead of Exception I use IOException I cannot caught the exception - a 
NullPointerException is thrown

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.ejml.ops.ReadMatrixCsv.read(Unknown Source)
    at org.ejml.ops.MatrixIO.loadCSV(Unknown Source)
    at ipapas.mlj.MainFrame.loadFileJButtonActionPerformed(MainFrame.java:396)
    at ipapas.mlj.MainFrame.access$000(MainFrame.java:47)
If I enter number of rows less then the number that the file actually contains 
then no Exception is thrown.

regards,
Ioannis P.

Original issue reported on code.google.com by [email protected] on 7 Dec 2012 at 11:19

Replace use of D1Matrix64F.get/set by more performant alternatives if possible

For performance reasons internal classes in the EJML library (e.g. in 
MatrixMatrixMult) should not call D1Matrix64F.get() / .set() but use more 
efficient versions of these methods where available, e.g. 
DenseMatrix64F.unsafe_get() / .unsafe_set().

Internal classes are properly unit-tested so using unsafe versions of getters 
and setters is a safe way to improve performance. This would obviously require 
different implementations of an algorithm for different concrete matrix types.

Original issue reported on code.google.com by [email protected] on 23 Nov 2011 at 10:34

Add method elementDivide to CommonOps

What steps will reproduce the problem?
1. CommonOps.elementDiv(D1Matrix64F a , D1Matrix64F b )
2.
3.

What is the expected output? What do you see instead?
Performs the an element by element division operation.


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 26 Mar 2011 at 3:33

Feature Request: equals() and hashcode()

It'd be nice if equals() were overridden to call isIdentical with some
default tolerance. The hard part would be calculating hashcode() so that
two matrices that are equals() have the same hashcode().

Having equals() would make unit tests easier, and then having hashcode()
would just be for Java best practices. I'm not sure how to do this
best...maybe round each element of the matrix before computing a hash of it?

Original issue reported on code.google.com by [email protected] on 24 Apr 2010 at 4:24

Provide source code in public VCS

Hi,

I found this project and I like how it aims to allow for maximum efficiency
while at the same time providing an easier to use layer. I think it would
be useful for interested parties (and potential contributors) to track
progress via a VCS (e.g. SVN or Mercurial if Google Code is preferred).

Is there any reason why this is not done or is it planned?

Original issue reported on code.google.com by ismaelj on 18 Feb 2010 at 11:19

Matrix inverse is not correct when matrix is close to singular

What steps will reproduce the problem?
1. crate a SimpleMatrix like the following 2x3 matrix. Name it x
    67.037029  -61.565225  1
    12.015528  -74.2136835  1
2. SimpleMatrix result = x.transpose().mult(x).invert();



What is the expected output? What do you see instead?

The returned result is far from what Matlab gives me.
And Matlab appears to be correct (even though Matlab says the matrix is close 
to singular).

Matlab source code:
x=[67.037029 -61.565225 1; 12.015528 -74.2136835 1];
result = (x' * x) \ [1 0 0 ; 0 1 0; 0 0 1]

Using Matlab to calculate it, it returns the following:

1.0e+015 *

    0.0000   -0.0002   -0.0154
   -0.0002    0.0009    0.0669
   -0.0154    0.0669    5.1470

Warning: Matrix is close to singular or badly scaled.
         Results may be inaccurate. RCOND = 1.323178e-020.

Original issue reported on code.google.com by GalaxyH on 16 Nov 2011 at 9:49

MatrixFeatures.isPositiveDefinite modifies the matrix if sandwiched with invert()

What steps will reproduce the problem?
 m1 = new SimpleMatrix(..)
i1 = m1.invert();
MatrixFeatures.isPositiveDefinite(m1.getMatrix());
i2 = m1.invert

After this i1 != i2. 

Working code attached.

What is the expected output? What do you see instead?

I would expect that i1 == i2.

The attached code prints:

false
false
Type = dense , numRows = 2 , numCols = 2
 1.000  -2.000  
-0.000   1.000  

Type = dense , numRows = 2 , numCols = 2
-0.333   0.667  
 0.667  -0.333  



What version of the product are you using? On what operating system?

version of ejml: release 21 .
os: osx 10.7
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode) 

Please provide any additional information below.

Calling isPositiveDefinite with a copied densematrix solved the problem, still 
unexpected.

Original issue reported on code.google.com by [email protected] on 3 Apr 2013 at 3:18

Attachments:

nullspace()

What steps will reproduce the problem?
1.nullspace()
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


As far as i can say is that the (Right) Nullspace of the matrix A (as described 
in the SingularValueDecomposition-Class) is of the dimension n-rang(A)x n and 
not only one vector. Took me a while to figure out, that my matrix was the 
problem.

greets 
simon 

Original issue reported on code.google.com by [email protected] on 16 Aug 2011 at 10:48

Matrix rank seems incorrect for large matrices

What steps will reproduce the problem?
1. The matrix is shown below.
2. call and print SimpleMatrix.svd(true).rank()

What is the expected output? What do you see instead?

MATLAB computes rank = 27 which is expected but EJML computes 28.

What version of the product are you using? On what operating system?

0.25 on Mac OSX 10.10.

Please provide any additional information below.

Correct for small matrices.


Test matrix input:

       1     -32       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0      16     -16       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0      16       0       0       0       0       0       0      -4       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0      16      -1       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0      16       0      -1       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0      16       0       0      -1       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0      16       0       0       0      -1       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       1       0       0       0      -4       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0      16       0       0       0       0       0       0       0       0       0       0       0       0      -1       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       2     -32       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       8      -8       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       8       0      -8       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       8       0       0      -8       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       8       0       0       0      -8       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       1       0       0       0      -1       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       4      -1
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       1       0       0      -1       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       1       0      -1       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       1      -1       0
       0       0       0       0       1       0       0      -4       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       1       0      -4       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       1      -4       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       1      -1       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       1       0      -1       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       1       0       0      -1       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       1       0       0       0      -1       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       1       0       0       0      -4       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0      16     -16       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0      16      -1       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0      16       0      -1       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0      16       0       0      -1       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0      16       0       0       0      -1       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       1       0       0       0     -16       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0      64      -1       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       1       0       0     -16       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       1       0     -16       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       1     -16       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       1       0       0      -4       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       1       0      -4       0       0       0       0       0       0       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0       0       0       0       0       1      -4       0       0       0       0       0       0       0       0       0       0       0       0       0       0

Original issue reported on code.google.com by [email protected] on 4 Nov 2014 at 3:57

DenseMatrix64F.reshape() gives wrong result when saveValues is true

What steps will reproduce the problem?
1. consider the following matrix:

1 0
0 1

2. reshape it by adding a new column:
DenseMatrix64F.reshape(2, 3, true)

What is the expected output? What do you see instead?
Expected:
1 0 0
0 1 0

What I see:
1 0 0
1 0 0

What version of the product are you using? On what operating system?
Using the 0.17 version on Windows 7.


Please provide any additional information below.
When copying the original matrix, the internal array is simply copied into the 
new array, which is larger by the necessary amount of elements. This way the 
new elements get positioned to the END of the internal array, not to every 
numCol()th position.

Original issue reported on code.google.com by [email protected] on 22 Nov 2011 at 7:45

Support for huge matricies

I would be interested in adding support for huge matrices backed by memory 
mapped files.  This could support large, persisted matrices with minimal heap 
foot print.  On my blog I have an example of a "sparse" 1,000,000 x 1,000,000 
matrix which is rather slow but a matrix of 100,000 x 100,000 might be 
practical.

Original issue reported on code.google.com by [email protected] on 20 Jan 2012 at 9:20

CommonOps#mult does not behave as expected with c == a or c == b

Should the following do an in place multiplication?

DenseMatrix64F a = new DenseMatrix64F(4, 4);
DenseMatrix64F b = new DenseMatrix64F(4, 4);
// Set values ...
CommonOps.mult(a, b, a);

// Does a' = a * b ?

This seems to not work for me with my matrices. Maybe an argument check to 
prevent mis-use?



Original issue reported on code.google.com by [email protected] on 21 Jul 2010 at 3:22

Matrix inversion should fail if matrix contains NaN

If a matrix has elements with NaN in it it will produce garbage results but not 
detect the failure.  

Design note: Shouldn't waste cycles checking for NaN explicity, but would be 
nice if this could be easily detected.

Original issue reported on code.google.com by [email protected] on 10 Nov 2013 at 10:38

Erroneous calculation of the determinant of a matrix

The calculation of the determinant of a Matrix seems to increase a lot when the 
dimension of a square matrix increases. Way(!) beyond any appropriate tolerance.

I would aspect at most a tolerance about 1e-15 for the following test, while 
the error value seems to increase to infinity with increasing dimension.

The following shows the results for the difference between the determinant of a 
random matrix and its transpose (det(A) - det(A^T)). The correct value would be 
0 for each given case.

1. column: Dimension
2. column: Error using Colt
3. column: Error using EJML
4. column: Error using EJML for det(A) - det((A^t)^t), to differentiate whether 
det() or ^t seems to be erroneous.

1   0.0         0.0         0.0
2   -5.551115123125783E-17  0.0         0.0
3   2.7755575615628914E-17  1.3877787807814457E-17  0.0
4   2.7755575615628914E-17  1.3877787807814457E-17  0.0
5   -6.938893903907228E-18  -6.938893903907228E-17  0.0
6   -6.938893903907228E-18  3.642919299551295E-17   0.0
7   -6.938893903907228E-18  -3.469446951953614E-18  0.0
8   -2.7755575615628914E-17 3.469446951953614E-18   0.0
9   -2.7755575615628914E-17 1.9081958235744878E-17  0.0
10  2.7755575615628914E-17  -5.551115123125783E-17  0.0
11  2.7755575615628914E-17  3.122502256758253E-17   0.0
12  6.938893903907228E-18   -6.288372600415926E-18  0.0
13  6.938893903907228E-18   0.0         0.0
14  6.938893903907228E-18   1.610040226140974E-17   0.0
15  -3.122502256758253E-17  9.367506770274758E-17   0.0
16  -1.3877787807814457E-17 -2.7755575615628914E-17 0.0
17  -1.3877787807814457E-17 -1.0625181290357943E-17 0.0
18  1.3877787807814457E-17  -7.806255641895632E-17  0.0
19  -1.3877787807814457E-17 5.551115123125783E-17   0.0
20  0.0         -1.734723475976807E-18  0.0
21  0.0         -6.938893903907228E-17  0.0
22  6.938893903907228E-18   0.0         0.0
23  0.0         -9.43689570931383E-16   0.0
24  -1.734723475976807E-18  5.551115123125783E-17   0.0
25  6.938893903907228E-17   1.8318679906315083E-15  0.0
26  1.734723475976807E-18   2.7755575615628914E-17  0.0
27  2.7755575615628914E-17  -2.7755575615628914E-15 0.0
28  2.7755575615628914E-17  1.3877787807814457E-15  0.0
29  9.71445146547012E-17    -3.552713678800501E-15  0.0
30  6.938893903907228E-18   6.217248937900877E-15   0.0
31  3.469446951953614E-18   -1.5987211554602254E-13 0.0
32  5.551115123125783E-17   -3.552713678800501E-14  0.0
33  5.551115123125783E-17   4.618527782440651E-14   0.0
34  -1.3877787807814457E-17 -5.790923296444817E-13  0.0
35  2.7755575615628914E-17  1.7053025658242404E-13  0.0
36  5.551115123125783E-17   2.2737367544323206E-13  0.0
37  5.551115123125783E-17   -4.831690603168681E-13  0.0
38  -5.204170427930421E-18  2.3447910280083306E-13  0.0
39  -5.551115123125783E-17  1.0800249583553523E-12  0.0
40  -5.551115123125783E-17  1.8189894035458565E-12  0.0
41  8.326672684688674E-17   1.1084466677857563E-12  0.0
42  8.326672684688674E-17   1.5916157281026244E-12  0.0
43  -1.1102230246251565E-16 -9.094947017729282E-12  0.0
44  -2.7755575615628914E-17 -7.457856554538012E-11  0.0
45  -2.7755575615628914E-17 2.5579538487363607E-13  0.0
46  8.326672684688674E-17   1.6825651982799172E-11  0.0
47  -6.938893903907228E-18  2.1373125491663814E-10  0.0
48  -9.540979117872439E-18  -3.166496753692627E-8   0.0
49  2.7755575615628914E-17  2.6193447411060333E-10  0.0
50  -6.938893903907228E-18  -3.725290298461914E-9   0.0
51  2.7755575615628914E-17  -1.0739313438534737E-8  0.0
52  1.0408340855860843E-17  4.470348358154297E-7    0.0
53  1.0408340855860843E-17  1.0710209608078003E-8   0.0
54  -5.551115123125783E-17  9.575160220265388E-9    0.0
55  -2.7755575615628914E-17 -8.032657206058502E-9   0.0
56  0.0         4.842877388000488E-8    0.0
57  -1.0408340855860843E-17 5.9604644775390625E-8   0.0
58  -1.1102230246251565E-16 0.0         0.0
59  1.3877787807814457E-17  1.430511474609375E-6    0.0
60  6.938893903907228E-18   -3.4332275390625E-5 0.0
61  1.3877787807814457E-17  0.0         0.0
62  2.7755575615628914E-17  -3.039836883544922E-6   0.0
63  -1.3877787807814457E-17 7.32421875E-4       0.0
64  -1.3877787807814457E-17 2.09808349609375E-5 0.0
65  6.938893903907228E-18   -0.00140380859375   0.0
66  -8.673617379884035E-19  -0.001613616943359375   0.0
67  2.7755575615628914E-17  -6.103515625E-5     0.0
68  -6.938893903907228E-18  0.0010986328125     0.0
69  5.551115123125783E-17   -0.0028076171875    0.0
70  1.1492543028346347E-17  -0.029296875        0.0
71  4.163336342344337E-17   0.0078125       0.0
72  3.469446951953614E-18   0.25            0.0
73  -4.163336342344337E-17  6.46875         0.0
74  0.0         -2.4375         0.0
75  -5.551115123125783E-17  -0.5625         0.0
76  1.3877787807814457E-17  2.4375          0.0
77  0.0         1.5         0.0
78  -1.3877787807814457E-17 1120.0          0.0
79  3.8163916471489756E-17  296.0           0.0
80  -1.3877787807814457E-17 -4160.0         0.0
81  5.551115123125783E-17   1088.0          0.0
82  5.095750210681871E-18   -52736.0        0.0
83  0.0         34176.0         0.0
84  4.163336342344337E-17   5632.0          0.0
85  6.938893903907228E-18   24832.0         0.0
86  5.551115123125783E-17   293072.0        0.0
87  -5.551115123125783E-17  229376.0        0.0
88  5.551115123125783E-17   1638400.0       0.0
89  1.3877787807814457E-17  -851968.0       0.0
90  8.348356728138384E-18   1245184.0       0.0
91  -1.3877787807814457E-17 851968.0        0.0
92  0.0         -7.5497472E7        0.0
93  -2.7755575615628914E-17 -6.3963136E7        0.0
94  2.0816681711721685E-17  4.9283072E7     0.0
95  -6.938893903907228E-18  8.9915392E7     0.0
96  5.551115123125783E-17   7.38197504E8        0.0
97  -4.163336342344337E-17  -9.663676416E9      0.0
98  0.0         -2.952790016E9      0.0
99  -1.1102230246251565E-16 -2.10453397504E11   0.0


Code snippet to reproduce:

for(int i = 1; i < 100; i++) {
  // Dimension
  System.out.print(i + "\t");

  // Error using Colt
  DoubleFactory2D doubleFactory2D = DoubleFactory2D.dense;
  DoubleMatrix2D matrixCern = doubleFactory2D.random(4,4);
  Algebra algebra = new Algebra();
  System.out.print(algebra.det(matrixCern) - algebra.det(algebra.transpose(matrixCern)) + "\t");

  // Error using EJML ...
  Random random = new Random();
  DenseMatrix64F matrix = RandomMatrices.createRandom(i, i, random);
  System.out.print(CommonOps.det(matrix) - CommonOps.det(CommonOps.transpose(matrix, null)) + "\t");
  // ... for det(A) - det((A^t)^t), to differentiate whether det() or ^t seems to be erroneous.
  System.out.println(CommonOps.det(matrix) - CommonOps.det(CommonOps.transpose(CommonOps.transpose(matrix, null), null)));
}

Original issue reported on code.google.com by [email protected] on 2 Oct 2013 at 9:37

Error : method copy() of type DenseMatrix64F

What steps will reproduce the problem?
1. I use EJML package with eclipse when i copied it i received this error
2.The method copy() of type DenseMatrix64F is not generic; it cannot be 
parameterized with arguments <DenseMatrix64F> TestSvdImplicitQrAlgorithm.java   

all the errors are related to this method would you please tell me why it is so




Original issue reported on code.google.com by [email protected] on 2 May 2012 at 8:17

Matrix reshape question

Hi all,

I have a question on the reshape method of org.ejml.data.DenseMatrix64F.java. 
If we want to keep the matrix data and just reshape it to, for example, make it 
bigger, the data doesn't stay in the same "logical" positions that it had 
before, as a consequence the logical matrix is altered, and I cannot see how 
the original data could be still used in a meaningful way. This option would be 
typically needed e.g. in dimensionality reduction algorithms, etc.

Would it make sense to consider an implementation that leaves each value in the 
same logical (i,j) position it had initially? E.g. something like:

@Override
public void reshape(int numRows, int numCols, boolean saveValues) {
    double[] d = new double[numRows * numCols];

    if (saveValues) {
        for (int i = 0, j = 0; i < numRows * numCols && j < getNumElements();) {
            if (j % this.numCols < numCols) {
                d[i++] = data[j++];
            } else {
                j += this.numCols - numCols;
            }
        }
    }

    this.data = d;

    this.numRows = numRows;
    this.numCols = numCols;
}

Any help is appreciated!

Cheers!

Original issue reported on code.google.com by [email protected] on 3 Dec 2013 at 12:41

Array index out of bound at with large matrix (such as 400000 * 400000)

What steps will reproduce the problem?
1. SimpleMatrix s = new SimpleMatrix(400000, 400000);
2. For each row and column, set value = 0.5

What is the expected output? What do you see instead?
The values should be set without error. However, an exception is thrown 
(java.lang.ArrayIndexOutOfBoundsException).

What version of the product are you using? On what operating system?
EJML 0.15, on Windows 7 (64-bit).

Please provide any additional information below.
N/A.

Original issue reported on code.google.com by [email protected] on 31 Jan 2011 at 7:31

Attachments:

Request for additional element-wise matrix operators

Hello,

it seems to me that SimpleMatrix has no pow functions like in matlab "A .^ 2" 
or "A .^ B"

http://www.mathworks.it/it/help/matlab/ref/power.html

I think this should be added.

w4nderlust

Also a log and a exp functions could be helpful.

Original issue reported on code.google.com by [email protected] on 28 Jan 2013 at 11:41

Request for adding a multiplication method for more than two matrices

Hi Peter,

When I have to multiply more than two matrices (e.g., A*B*C*...), I try to 
search for a simple method defined in CommonOps but failed.  Is there any one 
could do this?  Or I guess it is not possible to implement such a method.

For a more specific situation in quadratic-form related computation, one has to 
compute C = A * B * A' (or C = A' * B * A).  I think this is possible to add a 
method as multQuadratic(A,B,C) to CommonOps, avoiding allocating temporary 
memory for tmp = A * B and then C = tmp * A'.

I do not find any other libraries implement such a method.  So I can only 
provide you:
http://en.wikipedia.org/wiki/Quadratic_form
for reference.

Original issue reported on code.google.com by [email protected] on 3 Jun 2013 at 12:42

MatrixFeatures.isSymmetric() returns true for non-symmetric matrices containint NaNs

This code snippet

        DenseMatrix64F m = new DenseMatrix64F(new double[][] {
                { 1.0, Double.NaN },
                { 3.0, 4.0 },
        });
        System.out.println(MatrixFeatures.isSymmetric(m));

will print 'true', which is wrong because the matrix is not symmetric. The code 
line 'if( diff > tol ) {' should be replaced by 'if (!(diff <= tol)) {' to also 
handle the NaN case correctly.

More methods involving tolerance checks of this kind may be affected because 
they use the same flawed tolerance computation logic, e.g. isSkewSymmetric(), 
isIdentical(), isInverse(), isOrthogonal(), isIdentity(), isConstantVal(), 
isNegative(), isUpperTriangle().

Original issue reported on code.google.com by [email protected] on 14 Apr 2011 at 6:26

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.