jingyuzhu / efficient-java-matrix-library

Automatically exported from code.google.com/p/efficient-java-matrix-library
0 stars 0 forks source link

Remove awt/swing dependancies from data/* for Android #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 lorraine...@gmail.com on 13 Mar 2011 at 4:03

GoogleCodeExporter commented 8 years ago
Just for the sake of clarity. I reported the above issue using my wife's 
account (d'oh).  It was reported by me, not her :)  If you reply to her, she'll 
probably not rewrite the patch against the latest svn HEAD.

Original comment by aidan.de...@gmail.com on 13 Mar 2011 at 4:05

GoogleCodeExporter commented 8 years ago
I was wondering when I wrote that if including GUI code might cause problem on 
embedded devices.  Maybe a better long term solution is to create an ant script 
to build it with no GUI/AWT code being referenced.  GUI code could be pushed 
into a new class called VisualizeMatrix.  The build script would then just omit 
VisualizeMatrix and MatrixComponent.

Does that sound like a good solution?

Original comment by peter.ab...@gmail.com on 14 Mar 2011 at 2:18

GoogleCodeExporter commented 8 years ago
That sounds like an excellent solution.  Many thanks for considering my 
use-case.

Original comment by aidan.de...@gmail.com on 14 Mar 2011 at 4:20

GoogleCodeExporter commented 8 years ago
Check out the downloads section for a new jar.  Let me know if that works.  To 
make a jar yourself from the latest SVN HEAD use "ant nogui".  BTW the location 
of SimpleMatrix has changed from the version of the code you are using.  It's 
in its own package now.

Original comment by peter.ab...@gmail.com on 16 Mar 2011 at 3:12

GoogleCodeExporter commented 8 years ago
I'm assuming that the jar works and there are no problems.  Been downloaded 
several times and no one has sent hate mail.

Original comment by peter.ab...@gmail.com on 29 Mar 2011 at 2:44