Permalink
Browse files

Added target to pom to generate sources through ant, generalized eige…

…nvalues, minor fixes.

Bumped version to 1.2.0
  • Loading branch information...
1 parent 0d2111c commit 91b728bece996a4d716ff8972c741b3f4d3bf1ff Mikio L. Braun committed Jan 7, 2011
View
@@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Define directories -->
- <property name="version" value="1.1.2" />
+ <property name="version" value="1.2.0" />
<property name="src" value="${basedir}/src/main/java" />
<property name="test" value="${basedir}/src/test/java" />
<property name="bin" value="${basedir}/target/classes" />
View
@@ -4,7 +4,7 @@
<groupId>org.jblas</groupId>
<artifactId>jblas</artifactId>
- <version>1.1.1</version>
+ <version>1.2.0</version>
<packaging>jar</packaging>
<name>jblas</name>
@@ -35,6 +35,23 @@
</archive>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-float-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant target="generate-float" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
@@ -117,24 +117,38 @@ public static ComplexDoubleMatrix eigenvalues(DoubleMatrix A) {
return new ComplexDoubleMatrix[]{V, ComplexDoubleMatrix.diag(E)};
}
+ /**
+ * Compute generalized eigenvalues of the problem A x = L B x.
+ *
+ * @param A symmetric Matrix A. Only the upper triangle will be considered.
+ * @param B symmetric Matrix B. Only the upper triangle will be considered.
+ * @return a vector of eigenvalues L.
+ */
+ public static DoubleMatrix symmetricGeneralizedEigenvalues(DoubleMatrix A, DoubleMatrix B) {
+ A.assertSquare();
+ B.assertSquare();
+ DoubleMatrix W = new DoubleMatrix(A.rows);
+ SimpleBlas.sygvd(1, 'N', 'U', A.dup(), B.dup(), W);
+ return W;
+ }
/**
* Solve a general problem A x = L B x.
*
- * @param a symmetric matrix A
- * @param b symmetric matrix B
+ * @param A symmetric matrix A
+ * @param B symmetric matrix B
* @return an array of matrices of length two. The first one is an array of the eigenvectors X
- * The second one is a vector containing the corresponding eigenvalues L.
+ * The second one is A vector containing the corresponding eigenvalues L.
*/
- public static DoubleMatrix[] symmetricGeneralizedEigenvectors(DoubleMatrix a, DoubleMatrix b) {
- a.assertSquare();
- b.assertSquare();
+ public static DoubleMatrix[] symmetricGeneralizedEigenvectors(DoubleMatrix A, DoubleMatrix B) {
+ A.assertSquare();
+ B.assertSquare();
DoubleMatrix[] result = new DoubleMatrix[2];
- DoubleMatrix A = a.dup();
- DoubleMatrix B = b.dup();
- DoubleMatrix W = new DoubleMatrix(A.rows);
- SimpleBlas.sygvd(1, 'V', 'U', A, B, W.data);
- result[0] = A;
+ DoubleMatrix dA = A.dup();
+ DoubleMatrix dB = B.dup();
+ DoubleMatrix W = new DoubleMatrix(dA.rows);
+ SimpleBlas.sygvd(1, 'V', 'U', dA, dB, W);
+ result[0] = dA;
result[1] = W;
return result;
}
@@ -216,24 +230,38 @@ public static ComplexFloatMatrix eigenvalues(FloatMatrix A) {
return new ComplexFloatMatrix[]{V, ComplexFloatMatrix.diag(E)};
}
+ /**
+ * Compute generalized eigenvalues of the problem A x = L B x.
+ *
+ * @param A symmetric Matrix A. Only the upper triangle will be considered.
+ * @param B symmetric Matrix B. Only the upper triangle will be considered.
+ * @return a vector of eigenvalues L.
+ */
+ public static FloatMatrix symmetricGeneralizedEigenvalues(FloatMatrix A, FloatMatrix B) {
+ A.assertSquare();
+ B.assertSquare();
+ FloatMatrix W = new FloatMatrix(A.rows);
+ SimpleBlas.sygvd(1, 'N', 'U', A.dup(), B.dup(), W);
+ return W;
+ }
/**
* Solve a general problem A x = L B x.
*
- * @param a symmetric matrix A
- * @param b symmetric matrix B
+ * @param A symmetric matrix A
+ * @param B symmetric matrix B
* @return an array of matrices of length two. The first one is an array of the eigenvectors X
- * The second one is a vector containing the corresponding eigenvalues L.
+ * The second one is A vector containing the corresponding eigenvalues L.
*/
- public static FloatMatrix[] symmetricGeneralizedEigenvectors(FloatMatrix a, FloatMatrix b) {
- a.assertSquare();
- b.assertSquare();
+ public static FloatMatrix[] symmetricGeneralizedEigenvectors(FloatMatrix A, FloatMatrix B) {
+ A.assertSquare();
+ B.assertSquare();
FloatMatrix[] result = new FloatMatrix[2];
- FloatMatrix A = a.dup();
- FloatMatrix B = b.dup();
- FloatMatrix W = new FloatMatrix(A.rows);
- SimpleBlas.sygvd(1, 'V', 'U', A, B, W.data);
- result[0] = A;
+ FloatMatrix dA = A.dup();
+ FloatMatrix dB = B.dup();
+ FloatMatrix W = new FloatMatrix(dA.rows);
+ SimpleBlas.sygvd(1, 'V', 'U', dA, dB, W);
+ result[0] = dA;
result[1] = W;
return result;
}
@@ -376,8 +376,8 @@ public static int geev(char jobvl, char jobvr, DoubleMatrix A,
return info;
}
- public static int sygvd(int itype, char jobz, char uplo, DoubleMatrix A, DoubleMatrix B, double[] w) {
- int info = NativeBlas.dsygvd(itype, jobz, uplo, A.rows, A.data, 0, A.rows, B.data, 0, B.rows, w, 0);
+ public static int sygvd(int itype, char jobz, char uplo, DoubleMatrix A, DoubleMatrix B, DoubleMatrix W) {
+ int info = NativeBlas.dsygvd(itype, jobz, uplo, A.rows, A.data, 0, A.rows, B.data, 0, B.rows, W.data, 0);
if (info == 0)
return 0;
else {
@@ -711,8 +711,8 @@ public static int geev(char jobvl, char jobvr, FloatMatrix A,
return info;
}
- public static int sygvd(int itype, char jobz, char uplo, FloatMatrix A, FloatMatrix B, float[] w) {
- int info = NativeBlas.ssygvd(itype, jobz, uplo, A.rows, A.data, 0, A.rows, B.data, 0, B.rows, w, 0);
+ public static int sygvd(int itype, char jobz, char uplo, FloatMatrix A, FloatMatrix B, FloatMatrix W) {
+ int info = NativeBlas.ssygvd(itype, jobz, uplo, A.rows, A.data, 0, A.rows, B.data, 0, B.rows, W.data, 0);
if (info == 0)
return 0;
else {
@@ -44,6 +44,8 @@
import org.jblas.util.Logger;
/**
+ * Test Class for org.jblas.Eigen
+ *
* @author mikio
*/
public class TestEigen extends TestCase {
@@ -88,5 +90,9 @@ public void testSymmetricEigenvalues() {
DoubleMatrix RHS = B.mmul(V).mmul(DoubleMatrix.diag(L));
assertEquals(0.0, LHS.sub(RHS).normmax(), 1e-3);
+
+ DoubleMatrix eigenvalues = Eigen.symmetricGeneralizedEigenvalues(A, B);
+
+ assertEquals(0.0, eigenvalues.sub(L).normmax(), 1e-3);
}
}
@@ -39,15 +39,15 @@
import junit.framework.TestCase;
public class TestSolve extends TestCase {
- public void testFaultySolveSymmetric() {
- DoubleMatrix A = new DoubleMatrix(3, 3, 2d, 1d, 0d, 2d, 1d, 2d, 0d, 1d, 2d);
- DoubleMatrix x = new DoubleMatrix(1, 3, 1d, 2d, 3d);
+ public void testFaultySolveSymmetric() {
+ DoubleMatrix A = new DoubleMatrix(3, 3, 2d, 1d, 0d, 2d, 1d, 2d, 0d, 1d, 2d);
+ DoubleMatrix x = new DoubleMatrix(1, 3, 1d, 2d, 3d);
- try {
- Solve.solveSymmetric(A, x);
- assertTrue(false);
- } catch(IllegalArgumentException ex) {
- assertEquals("XERBLA: Error on argument 8 (LDB) in DSYSV", ex.getMessage());
- }
- }
+ try {
+ Solve.solveSymmetric(A, x);
+ assertTrue(false);
+ } catch (IllegalArgumentException ex) {
+ assertEquals("XERBLA: Error on argument 8 (LDB) in DSYSV", ex.getMessage());
+ }
+ }
}

0 comments on commit 91b728b

Please sign in to comment.