Permalink
Browse files

git-svn-id: https://ml01.zrz.tu-berlin.de/svn/ida/private/mikio/java-…

…blas/trunk@4230 1449bcba-80d8-4576-a99e-0f548206d62b
  • Loading branch information...
1 parent 79a190b commit 33700889368eec7c5d895bf64fd4bc7049d87f74 MikioBraun committed Mar 27, 2009
Showing with 572 additions and 562 deletions.
  1. +2 −0 AUTHORS
  2. +31 −0 COPYING
  3. +8 −49 Makefile
  4. +21 −3 README
  5. +5 −5 nbproject/private/private.xml
  6. 0 scripts/{fortranwrapper → fortranwrapper.rb}
  7. +505 −505 src/org/jblas/la/DoubleMatrix.java
View
2 AUTHORS
@@ -0,0 +1,2 @@
+Mikio L. Braun - main developer
+Johannes Schaback - additional programming
View
31 COPYING
@@ -0,0 +1,31 @@
+Copyright (c) 2009, Mikio L. Braun and contributors
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of the Technische Universität Berlin nor the
+ names of its contributors may be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
57 Makefile
@@ -1,56 +1,15 @@
+# Load the output of the configuration files
+ifneq ($(wildcard configure.out),)
include configure.out
+else
+$(error Please run "./configure" first...)
+endif
ifneq ($(LAPACK_HOME),)
LAPACK=$(LAPACK_HOME)/SRC
BLAS=$(LAPACK_HOME)/BLAS/SRC
endif
-#LAPACK_OR_ATLAS=atlas
-
-#
-# GNU/Linux (actually, debian) settings
-#
-#ifeq ($(shell uname -o),GNU/Linux)
-#CC=gcc
-#CFLAGS=-fPIC -ggdb
-#INCDIRS=-Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
-#SO=so
-#LIB=lib
-#ifeq ($(LAPACK_OR_ATLAS),atlas)
-#$(info ---Using ATLAS build)
-#LD=g77
-#LDFLAGS=-shared -L$(ATLAS_HOME) -L$(LAPACK_HOME)
-#LD=gfortran
-#LOADLIBES=-llapack -lf77blas -latlas -llapack-fortran -lblas-fortran
-#else
-#$(info ---Using LAPACK build)
-#LD=g77
-#LD=gfortran
-#LDFLAGS=-shared -L$(LAPACK_HOME)
-#LOADLIBES=-llapack-fortran -lblas-fortran
-#endif
-#RUBY=ruby
-#
-# cygwin settings
-#
-#else
-#ifeq ($(ATLAS_HOME),)
-#$(error ATLAS_HOME undefined. Please set ATLAS_HOME to the files containg the atlas libraries.)
-#endif
-#CC=gcc
-#CFLAGS=-ggdb -D__int64='long long'
-#JAVADIR=$(shell cygpath -u $$JAVA_HOME)
-#ATLASDIR=$(shell cygpath -u $$ATLAS_HOME)
-#LAPACKDIR=$(shell cygpath -u $$LAPACK_HOME)
-#INCDIRS=-I"$(JAVADIR)/include/" -I"$(JAVADIR)/include/win32" -Iinclude
-#LD=gcc
-#LDFLAGS=-mno-cygwin -shared -Wl,--add-stdcall-alias -L$(ATLASDIR) -L$(LAPACKDIR)
-#LOADLIBES=-llapack_WINXP -llapack -lf77blas -lcblas -latlas -lg2c
-#SO=dll
-#LIB=
-#RUBY=ruby
-#endif
-
PACKAGE=org.jblas.la
# generate path from package name
@@ -73,7 +32,7 @@ PACKAGE_PATH=$(subst .,/,$(PACKAGE))
$(LD) $(LDFLAGS) -o $@ $^ $(LOADLIBES)
# the default target
-all : compileNative
+all : compile-native
compile-native : bin/$(LIB)jblas.$(SO)
@@ -92,8 +51,8 @@ realclean:
endif
# Generating the stubs. This target requires that the blas sources can be found in ~/src/blas/*.f
-src/$(PACKAGE_PATH)/Blas.java native/Blas.c: scripts/fortranwrapper scripts/fortran.rb scripts/fortran/java.rb scripts/java-class.java scripts/java-impl.c
- $(RUBY) scripts/fortranwrapper $(PACKAGE) Blas \
+src/$(PACKAGE_PATH)/Blas.java native/Blas.c: scripts/fortranwrapper.rb scripts/fortran.rb scripts/fortran/java.rb scripts/java-class.java scripts/java-impl.c
+ $(RUBY) scripts/fortranwrapper.rb $(PACKAGE) Blas \
$(BLAS)/*.f \
$(LAPACK)/[sd]gesv.f \
$(LAPACK)/[sd]sysv.f \
View
24 README
@@ -1,14 +1,17 @@
-jBLAS is a matrix library for Java which uses existing high
+jblas is a matrix library for Java which uses existing high
performance BLAS and LAPACK libraries like ATLAS.
+Version 0.1
+
INSTALL
-In principle, all you need is the jBLAS.jar in your
-classpath. jBLAS.jar will then automagically extract your platform
+In principle, all you need is the jblas.jar in your
+classpath. jblas.jar will then automagically extract your platform
dependent native library to a tempfile and load it from there. You can
also put that file somewhere in your load path ($LD_LIBRARY_PATH for
Linux, %PATH for Windows).
+
BUILDING
If you want to build jBLAS from the sources, you need to set up quite
@@ -25,6 +28,21 @@ generation scripts.
If you still want to build the source your own, see INSTALL for further
details.
+
+LICENSE
+
+jblas is distributed under a BSD-style license. See the file LICENSE
+for more information.
+
+
+BUGS
+
+If you encounter any bugs, feel free to go to http://jblas.org and
+register a ticket for them. Make sure to include as much information
+as possible. For configuration problems it would also be helpful to
+include the file "configure.log".
+
+
CONTRIBUTORS
Mikio Braun - mikio@cs.tu-berlin.de
View
10 nbproject/private/private.xml
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
- <data xmlns="http://www.netbeans.org/ns/profiler/1" profile-file-target="" profile-target="debugDirectBufferGC" version="0.4"/>
- <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
-</project-private>
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+ <data xmlns="http://www.netbeans.org/ns/profiler/1" profile-file-target="" profile-target="debugDirectBufferGC" version="0.4"/>
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+</project-private>
View
0 scripts/fortranwrapper → scripts/fortranwrapper.rb
File renamed without changes.
View
1,010 src/org/jblas/la/DoubleMatrix.java
@@ -2421,509 +2421,509 @@ public static DoubleMatrix loadAsciiFile(String filename) throws IOException {
gen_logical('and', '&', 'logical and'),
gen_logical('or', '|', 'logical or'),
gen_logical('xor', '^', 'logical xor'))
- #*/
-//RJPP-BEGIN------------------------------------------------------------
- /** Add a matrix (in place). */
- public DoubleMatrix addi(DoubleMatrix other) {
- return addi(other, this);
- }
-
- /** Add a matrix (in place). */
- public DoubleMatrix add(DoubleMatrix other) {
- return addi(other, new DoubleMatrix(rows, columns));
- }
-
- /** Add a scalar (in place). */
- public DoubleMatrix addi(double v) {
- return addi(v, this);
- }
-
- /** Add a scalar. */
- public DoubleMatrix add(double v) {
- return addi(v, new DoubleMatrix(rows, columns));
- }
-
- /** Subtract a matrix (in place). */
- public DoubleMatrix subi(DoubleMatrix other) {
- return subi(other, this);
- }
-
- /** Subtract a matrix (in place). */
- public DoubleMatrix sub(DoubleMatrix other) {
- return subi(other, new DoubleMatrix(rows, columns));
- }
-
- /** Subtract a scalar (in place). */
- public DoubleMatrix subi(double v) {
- return subi(v, this);
- }
-
- /** Subtract a scalar. */
- public DoubleMatrix sub(double v) {
- return subi(v, new DoubleMatrix(rows, columns));
- }
-
- /** (right-)subtract a matrix (in place). */
- public DoubleMatrix rsubi(DoubleMatrix other) {
- return rsubi(other, this);
- }
-
- /** (right-)subtract a matrix (in place). */
- public DoubleMatrix rsub(DoubleMatrix other) {
- return rsubi(other, new DoubleMatrix(rows, columns));
- }
-
- /** (right-)subtract a scalar (in place). */
- public DoubleMatrix rsubi(double v) {
- return rsubi(v, this);
- }
-
- /** (right-)subtract a scalar. */
- public DoubleMatrix rsub(double v) {
- return rsubi(v, new DoubleMatrix(rows, columns));
- }
-
- /** Elementwise divide by a matrix (in place). */
- public DoubleMatrix divi(DoubleMatrix other) {
- return divi(other, this);
- }
-
- /** Elementwise divide by a matrix (in place). */
- public DoubleMatrix div(DoubleMatrix other) {
- return divi(other, new DoubleMatrix(rows, columns));
- }
-
- /** Elementwise divide by a scalar (in place). */
- public DoubleMatrix divi(double v) {
- return divi(v, this);
- }
-
- /** Elementwise divide by a scalar. */
- public DoubleMatrix div(double v) {
- return divi(v, new DoubleMatrix(rows, columns));
- }
-
- /** (right-)elementwise divide by a matrix (in place). */
- public DoubleMatrix rdivi(DoubleMatrix other) {
- return rdivi(other, this);
- }
-
- /** (right-)elementwise divide by a matrix (in place). */
- public DoubleMatrix rdiv(DoubleMatrix other) {
- return rdivi(other, new DoubleMatrix(rows, columns));
- }
-
- /** (right-)elementwise divide by a scalar (in place). */
- public DoubleMatrix rdivi(double v) {
- return rdivi(v, this);
- }
-
- /** (right-)elementwise divide by a scalar. */
- public DoubleMatrix rdiv(double v) {
- return rdivi(v, new DoubleMatrix(rows, columns));
- }
-
- /** Elementwise multiply by a matrix (in place). */
- public DoubleMatrix muli(DoubleMatrix other) {
- return muli(other, this);
- }
-
- /** Elementwise multiply by a matrix (in place). */
- public DoubleMatrix mul(DoubleMatrix other) {
- return muli(other, new DoubleMatrix(rows, columns));
- }
-
- /** Elementwise multiply by a scalar (in place). */
- public DoubleMatrix muli(double v) {
- return muli(v, this);
- }
-
- /** Elementwise multiply by a scalar. */
- public DoubleMatrix mul(double v) {
- return muli(v, new DoubleMatrix(rows, columns));
- }
-
- /** Matrix-multiply by a matrix (in place). */
- public DoubleMatrix mmuli(DoubleMatrix other) {
- return mmuli(other, this);
- }
-
- /** Matrix-multiply by a matrix (in place). */
- public DoubleMatrix mmul(DoubleMatrix other) {
- return mmuli(other, new DoubleMatrix(rows, other.columns));
- }
-
- /** Matrix-multiply by a scalar (in place). */
- public DoubleMatrix mmuli(double v) {
- return mmuli(v, this);
- }
-
- /** Matrix-multiply by a scalar. */
- public DoubleMatrix mmul(double v) {
- return mmuli(v, new DoubleMatrix(rows, columns));
- }
-
- /** Test for "less than" (in-place). */
- public DoubleMatrix lti(DoubleMatrix other, DoubleMatrix result) {
- if (other.isScalar())
- return lti(other.scalar(), result);
-
- assertSameLength(other);
- ensureResultLength(other, result);
-
- for (int i = 0; i < length; i++)
- result.put(i, get(i) < other.get(i) ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for "less than" (in-place). */
- public DoubleMatrix lti(DoubleMatrix other) {
- return lti(other, this);
- }
-
- /** Test for "less than". */
- public DoubleMatrix lt(DoubleMatrix other) {
- return lti(other, new DoubleMatrix(rows, columns));
- }
-
- /** Test for "less than" against a scalar (in-place). */
- public DoubleMatrix lti(double value, DoubleMatrix result) {
- ensureResultLength(null, result);
- for (int i = 0; i < length; i++)
- result.put(i, get(i) < value ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for "less than" against a scalar (in-place). */
- public DoubleMatrix lti(double value) {
- return lti(value, this);
- }
-
- /** test for "less than" against a scalar. */
- public DoubleMatrix lt(double value) {
- return lti(value, new DoubleMatrix(rows, columns));
- }
-
- /** Test for "greater than" (in-place). */
- public DoubleMatrix gti(DoubleMatrix other, DoubleMatrix result) {
- if (other.isScalar())
- return gti(other.scalar(), result);
-
- assertSameLength(other);
- ensureResultLength(other, result);
-
- for (int i = 0; i < length; i++)
- result.put(i, get(i) > other.get(i) ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for "greater than" (in-place). */
- public DoubleMatrix gti(DoubleMatrix other) {
- return gti(other, this);
- }
-
- /** Test for "greater than". */
- public DoubleMatrix gt(DoubleMatrix other) {
- return gti(other, new DoubleMatrix(rows, columns));
- }
-
- /** Test for "greater than" against a scalar (in-place). */
- public DoubleMatrix gti(double value, DoubleMatrix result) {
- ensureResultLength(null, result);
- for (int i = 0; i < length; i++)
- result.put(i, get(i) > value ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for "greater than" against a scalar (in-place). */
- public DoubleMatrix gti(double value) {
- return gti(value, this);
- }
-
- /** test for "greater than" against a scalar. */
- public DoubleMatrix gt(double value) {
- return gti(value, new DoubleMatrix(rows, columns));
- }
-
- /** Test for "less than or equal" (in-place). */
- public DoubleMatrix lei(DoubleMatrix other, DoubleMatrix result) {
- if (other.isScalar())
- return lei(other.scalar(), result);
-
- assertSameLength(other);
- ensureResultLength(other, result);
-
- for (int i = 0; i < length; i++)
- result.put(i, get(i) <= other.get(i) ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for "less than or equal" (in-place). */
- public DoubleMatrix lei(DoubleMatrix other) {
- return lei(other, this);
- }
-
- /** Test for "less than or equal". */
- public DoubleMatrix le(DoubleMatrix other) {
- return lei(other, new DoubleMatrix(rows, columns));
- }
-
- /** Test for "less than or equal" against a scalar (in-place). */
- public DoubleMatrix lei(double value, DoubleMatrix result) {
- ensureResultLength(null, result);
- for (int i = 0; i < length; i++)
- result.put(i, get(i) <= value ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for "less than or equal" against a scalar (in-place). */
- public DoubleMatrix lei(double value) {
- return lei(value, this);
- }
-
- /** test for "less than or equal" against a scalar. */
- public DoubleMatrix le(double value) {
- return lei(value, new DoubleMatrix(rows, columns));
- }
-
- /** Test for "greater than or equal" (in-place). */
- public DoubleMatrix gei(DoubleMatrix other, DoubleMatrix result) {
- if (other.isScalar())
- return gei(other.scalar(), result);
-
- assertSameLength(other);
- ensureResultLength(other, result);
-
- for (int i = 0; i < length; i++)
- result.put(i, get(i) >= other.get(i) ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for "greater than or equal" (in-place). */
- public DoubleMatrix gei(DoubleMatrix other) {
- return gei(other, this);
- }
-
- /** Test for "greater than or equal". */
- public DoubleMatrix ge(DoubleMatrix other) {
- return gei(other, new DoubleMatrix(rows, columns));
- }
-
- /** Test for "greater than or equal" against a scalar (in-place). */
- public DoubleMatrix gei(double value, DoubleMatrix result) {
- ensureResultLength(null, result);
- for (int i = 0; i < length; i++)
- result.put(i, get(i) >= value ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for "greater than or equal" against a scalar (in-place). */
- public DoubleMatrix gei(double value) {
- return gei(value, this);
- }
-
- /** test for "greater than or equal" against a scalar. */
- public DoubleMatrix ge(double value) {
- return gei(value, new DoubleMatrix(rows, columns));
- }
-
- /** Test for equality (in-place). */
- public DoubleMatrix eqi(DoubleMatrix other, DoubleMatrix result) {
- if (other.isScalar())
- return eqi(other.scalar(), result);
-
- assertSameLength(other);
- ensureResultLength(other, result);
-
- for (int i = 0; i < length; i++)
- result.put(i, get(i) == other.get(i) ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for equality (in-place). */
- public DoubleMatrix eqi(DoubleMatrix other) {
- return eqi(other, this);
- }
-
- /** Test for equality. */
- public DoubleMatrix eq(DoubleMatrix other) {
- return eqi(other, new DoubleMatrix(rows, columns));
- }
-
- /** Test for equality against a scalar (in-place). */
- public DoubleMatrix eqi(double value, DoubleMatrix result) {
- ensureResultLength(null, result);
- for (int i = 0; i < length; i++)
- result.put(i, get(i) == value ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for equality against a scalar (in-place). */
- public DoubleMatrix eqi(double value) {
- return eqi(value, this);
- }
-
- /** test for equality against a scalar. */
- public DoubleMatrix eq(double value) {
- return eqi(value, new DoubleMatrix(rows, columns));
- }
-
- /** Test for inequality (in-place). */
- public DoubleMatrix nei(DoubleMatrix other, DoubleMatrix result) {
- if (other.isScalar())
- return nei(other.scalar(), result);
-
- assertSameLength(other);
- ensureResultLength(other, result);
-
- for (int i = 0; i < length; i++)
- result.put(i, get(i) != other.get(i) ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for inequality (in-place). */
- public DoubleMatrix nei(DoubleMatrix other) {
- return nei(other, this);
- }
-
- /** Test for inequality. */
- public DoubleMatrix ne(DoubleMatrix other) {
- return nei(other, new DoubleMatrix(rows, columns));
- }
-
- /** Test for inequality against a scalar (in-place). */
- public DoubleMatrix nei(double value, DoubleMatrix result) {
- ensureResultLength(null, result);
- for (int i = 0; i < length; i++)
- result.put(i, get(i) != value ? 1.0 : 0.0);
- return result;
- }
-
- /** Test for inequality against a scalar (in-place). */
- public DoubleMatrix nei(double value) {
- return nei(value, this);
- }
-
- /** test for inequality against a scalar. */
- public DoubleMatrix ne(double value) {
- return nei(value, new DoubleMatrix(rows, columns));
- }
-
- /** Compute elementwise logical and (in-place). */
- public DoubleMatrix andi(DoubleMatrix other, DoubleMatrix result) {
- assertSameLength(other);
- ensureResultLength(other, result);
-
- for (int i = 0; i < length; i++)
- result.put(i, (get(i) != 0.0) & (other.get(i) != 0.0) ? 1.0 : 0.0);
- return result;
- }
-
- /** Compute elementwise logical and (in-place). */
- public DoubleMatrix andi(DoubleMatrix other) {
- return andi(other, this);
- }
-
- /** Compute elementwise logical and. */
- public DoubleMatrix and(DoubleMatrix other) {
- return andi(other, new DoubleMatrix(rows, columns));
- }
-
- /** Compute elementwise logical and against a scalar (in-place). */
- public DoubleMatrix andi(double value, DoubleMatrix result) {
- ensureResultLength(null, result);
- boolean val = (value != 0.0);
- for (int i = 0; i < length; i++)
- result.put(i, (get(i) != 0.0) & val ? 1.0 : 0.0);
- return result;
- }
-
- /** Compute elementwise logical and against a scalar (in-place). */
- public DoubleMatrix andi(double value) {
- return andi(value, this);
- }
-
- /** Compute elementwise logical and against a scalar. */
- public DoubleMatrix and(double value) {
- return andi(value, new DoubleMatrix(rows, columns));
- }
-
- /** Compute elementwise logical or (in-place). */
- public DoubleMatrix ori(DoubleMatrix other, DoubleMatrix result) {
- assertSameLength(other);
- ensureResultLength(other, result);
-
- for (int i = 0; i < length; i++)
- result.put(i, (get(i) != 0.0) | (other.get(i) != 0.0) ? 1.0 : 0.0);
- return result;
- }
-
- /** Compute elementwise logical or (in-place). */
- public DoubleMatrix ori(DoubleMatrix other) {
- return ori(other, this);
- }
-
- /** Compute elementwise logical or. */
- public DoubleMatrix or(DoubleMatrix other) {
- return ori(other, new DoubleMatrix(rows, columns));
- }
-
- /** Compute elementwise logical or against a scalar (in-place). */
- public DoubleMatrix ori(double value, DoubleMatrix result) {
- ensureResultLength(null, result);
- boolean val = (value != 0.0);
- for (int i = 0; i < length; i++)
- result.put(i, (get(i) != 0.0) | val ? 1.0 : 0.0);
- return result;
- }
-
- /** Compute elementwise logical or against a scalar (in-place). */
- public DoubleMatrix ori(double value) {
- return ori(value, this);
- }
-
- /** Compute elementwise logical or against a scalar. */
- public DoubleMatrix or(double value) {
- return ori(value, new DoubleMatrix(rows, columns));
- }
-
- /** Compute elementwise logical xor (in-place). */
- public DoubleMatrix xori(DoubleMatrix other, DoubleMatrix result) {
- assertSameLength(other);
- ensureResultLength(other, result);
-
- for (int i = 0; i < length; i++)
- result.put(i, (get(i) != 0.0) ^ (other.get(i) != 0.0) ? 1.0 : 0.0);
- return result;
- }
-
- /** Compute elementwise logical xor (in-place). */
- public DoubleMatrix xori(DoubleMatrix other) {
- return xori(other, this);
- }
-
- /** Compute elementwise logical xor. */
- public DoubleMatrix xor(DoubleMatrix other) {
- return xori(other, new DoubleMatrix(rows, columns));
- }
-
- /** Compute elementwise logical xor against a scalar (in-place). */
- public DoubleMatrix xori(double value, DoubleMatrix result) {
- ensureResultLength(null, result);
- boolean val = (value != 0.0);
- for (int i = 0; i < length; i++)
- result.put(i, (get(i) != 0.0) ^ val ? 1.0 : 0.0);
- return result;
- }
-
- /** Compute elementwise logical xor against a scalar (in-place). */
- public DoubleMatrix xori(double value) {
- return xori(value, this);
- }
-
- /** Compute elementwise logical xor against a scalar. */
- public DoubleMatrix xor(double value) {
- return xori(value, new DoubleMatrix(rows, columns));
- }
-//RJPP-END--------------------------------------------------------------
+ #*/
+//RJPP-BEGIN------------------------------------------------------------
+ /** Add a matrix (in place). */
+ public DoubleMatrix addi(DoubleMatrix other) {
+ return addi(other, this);
+ }
+
+ /** Add a matrix (in place). */
+ public DoubleMatrix add(DoubleMatrix other) {
+ return addi(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Add a scalar (in place). */
+ public DoubleMatrix addi(double v) {
+ return addi(v, this);
+ }
+
+ /** Add a scalar. */
+ public DoubleMatrix add(double v) {
+ return addi(v, new DoubleMatrix(rows, columns));
+ }
+
+ /** Subtract a matrix (in place). */
+ public DoubleMatrix subi(DoubleMatrix other) {
+ return subi(other, this);
+ }
+
+ /** Subtract a matrix (in place). */
+ public DoubleMatrix sub(DoubleMatrix other) {
+ return subi(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Subtract a scalar (in place). */
+ public DoubleMatrix subi(double v) {
+ return subi(v, this);
+ }
+
+ /** Subtract a scalar. */
+ public DoubleMatrix sub(double v) {
+ return subi(v, new DoubleMatrix(rows, columns));
+ }
+
+ /** (right-)subtract a matrix (in place). */
+ public DoubleMatrix rsubi(DoubleMatrix other) {
+ return rsubi(other, this);
+ }
+
+ /** (right-)subtract a matrix (in place). */
+ public DoubleMatrix rsub(DoubleMatrix other) {
+ return rsubi(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** (right-)subtract a scalar (in place). */
+ public DoubleMatrix rsubi(double v) {
+ return rsubi(v, this);
+ }
+
+ /** (right-)subtract a scalar. */
+ public DoubleMatrix rsub(double v) {
+ return rsubi(v, new DoubleMatrix(rows, columns));
+ }
+
+ /** Elementwise divide by a matrix (in place). */
+ public DoubleMatrix divi(DoubleMatrix other) {
+ return divi(other, this);
+ }
+
+ /** Elementwise divide by a matrix (in place). */
+ public DoubleMatrix div(DoubleMatrix other) {
+ return divi(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Elementwise divide by a scalar (in place). */
+ public DoubleMatrix divi(double v) {
+ return divi(v, this);
+ }
+
+ /** Elementwise divide by a scalar. */
+ public DoubleMatrix div(double v) {
+ return divi(v, new DoubleMatrix(rows, columns));
+ }
+
+ /** (right-)elementwise divide by a matrix (in place). */
+ public DoubleMatrix rdivi(DoubleMatrix other) {
+ return rdivi(other, this);
+ }
+
+ /** (right-)elementwise divide by a matrix (in place). */
+ public DoubleMatrix rdiv(DoubleMatrix other) {
+ return rdivi(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** (right-)elementwise divide by a scalar (in place). */
+ public DoubleMatrix rdivi(double v) {
+ return rdivi(v, this);
+ }
+
+ /** (right-)elementwise divide by a scalar. */
+ public DoubleMatrix rdiv(double v) {
+ return rdivi(v, new DoubleMatrix(rows, columns));
+ }
+
+ /** Elementwise multiply by a matrix (in place). */
+ public DoubleMatrix muli(DoubleMatrix other) {
+ return muli(other, this);
+ }
+
+ /** Elementwise multiply by a matrix (in place). */
+ public DoubleMatrix mul(DoubleMatrix other) {
+ return muli(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Elementwise multiply by a scalar (in place). */
+ public DoubleMatrix muli(double v) {
+ return muli(v, this);
+ }
+
+ /** Elementwise multiply by a scalar. */
+ public DoubleMatrix mul(double v) {
+ return muli(v, new DoubleMatrix(rows, columns));
+ }
+
+ /** Matrix-multiply by a matrix (in place). */
+ public DoubleMatrix mmuli(DoubleMatrix other) {
+ return mmuli(other, this);
+ }
+
+ /** Matrix-multiply by a matrix (in place). */
+ public DoubleMatrix mmul(DoubleMatrix other) {
+ return mmuli(other, new DoubleMatrix(rows, other.columns));
+ }
+
+ /** Matrix-multiply by a scalar (in place). */
+ public DoubleMatrix mmuli(double v) {
+ return mmuli(v, this);
+ }
+
+ /** Matrix-multiply by a scalar. */
+ public DoubleMatrix mmul(double v) {
+ return mmuli(v, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for "less than" (in-place). */
+ public DoubleMatrix lti(DoubleMatrix other, DoubleMatrix result) {
+ if (other.isScalar())
+ return lti(other.scalar(), result);
+
+ assertSameLength(other);
+ ensureResultLength(other, result);
+
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) < other.get(i) ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for "less than" (in-place). */
+ public DoubleMatrix lti(DoubleMatrix other) {
+ return lti(other, this);
+ }
+
+ /** Test for "less than". */
+ public DoubleMatrix lt(DoubleMatrix other) {
+ return lti(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for "less than" against a scalar (in-place). */
+ public DoubleMatrix lti(double value, DoubleMatrix result) {
+ ensureResultLength(null, result);
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) < value ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for "less than" against a scalar (in-place). */
+ public DoubleMatrix lti(double value) {
+ return lti(value, this);
+ }
+
+ /** test for "less than" against a scalar. */
+ public DoubleMatrix lt(double value) {
+ return lti(value, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for "greater than" (in-place). */
+ public DoubleMatrix gti(DoubleMatrix other, DoubleMatrix result) {
+ if (other.isScalar())
+ return gti(other.scalar(), result);
+
+ assertSameLength(other);
+ ensureResultLength(other, result);
+
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) > other.get(i) ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for "greater than" (in-place). */
+ public DoubleMatrix gti(DoubleMatrix other) {
+ return gti(other, this);
+ }
+
+ /** Test for "greater than". */
+ public DoubleMatrix gt(DoubleMatrix other) {
+ return gti(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for "greater than" against a scalar (in-place). */
+ public DoubleMatrix gti(double value, DoubleMatrix result) {
+ ensureResultLength(null, result);
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) > value ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for "greater than" against a scalar (in-place). */
+ public DoubleMatrix gti(double value) {
+ return gti(value, this);
+ }
+
+ /** test for "greater than" against a scalar. */
+ public DoubleMatrix gt(double value) {
+ return gti(value, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for "less than or equal" (in-place). */
+ public DoubleMatrix lei(DoubleMatrix other, DoubleMatrix result) {
+ if (other.isScalar())
+ return lei(other.scalar(), result);
+
+ assertSameLength(other);
+ ensureResultLength(other, result);
+
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) <= other.get(i) ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for "less than or equal" (in-place). */
+ public DoubleMatrix lei(DoubleMatrix other) {
+ return lei(other, this);
+ }
+
+ /** Test for "less than or equal". */
+ public DoubleMatrix le(DoubleMatrix other) {
+ return lei(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for "less than or equal" against a scalar (in-place). */
+ public DoubleMatrix lei(double value, DoubleMatrix result) {
+ ensureResultLength(null, result);
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) <= value ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for "less than or equal" against a scalar (in-place). */
+ public DoubleMatrix lei(double value) {
+ return lei(value, this);
+ }
+
+ /** test for "less than or equal" against a scalar. */
+ public DoubleMatrix le(double value) {
+ return lei(value, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for "greater than or equal" (in-place). */
+ public DoubleMatrix gei(DoubleMatrix other, DoubleMatrix result) {
+ if (other.isScalar())
+ return gei(other.scalar(), result);
+
+ assertSameLength(other);
+ ensureResultLength(other, result);
+
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) >= other.get(i) ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for "greater than or equal" (in-place). */
+ public DoubleMatrix gei(DoubleMatrix other) {
+ return gei(other, this);
+ }
+
+ /** Test for "greater than or equal". */
+ public DoubleMatrix ge(DoubleMatrix other) {
+ return gei(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for "greater than or equal" against a scalar (in-place). */
+ public DoubleMatrix gei(double value, DoubleMatrix result) {
+ ensureResultLength(null, result);
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) >= value ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for "greater than or equal" against a scalar (in-place). */
+ public DoubleMatrix gei(double value) {
+ return gei(value, this);
+ }
+
+ /** test for "greater than or equal" against a scalar. */
+ public DoubleMatrix ge(double value) {
+ return gei(value, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for equality (in-place). */
+ public DoubleMatrix eqi(DoubleMatrix other, DoubleMatrix result) {
+ if (other.isScalar())
+ return eqi(other.scalar(), result);
+
+ assertSameLength(other);
+ ensureResultLength(other, result);
+
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) == other.get(i) ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for equality (in-place). */
+ public DoubleMatrix eqi(DoubleMatrix other) {
+ return eqi(other, this);
+ }
+
+ /** Test for equality. */
+ public DoubleMatrix eq(DoubleMatrix other) {
+ return eqi(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for equality against a scalar (in-place). */
+ public DoubleMatrix eqi(double value, DoubleMatrix result) {
+ ensureResultLength(null, result);
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) == value ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for equality against a scalar (in-place). */
+ public DoubleMatrix eqi(double value) {
+ return eqi(value, this);
+ }
+
+ /** test for equality against a scalar. */
+ public DoubleMatrix eq(double value) {
+ return eqi(value, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for inequality (in-place). */
+ public DoubleMatrix nei(DoubleMatrix other, DoubleMatrix result) {
+ if (other.isScalar())
+ return nei(other.scalar(), result);
+
+ assertSameLength(other);
+ ensureResultLength(other, result);
+
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) != other.get(i) ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for inequality (in-place). */
+ public DoubleMatrix nei(DoubleMatrix other) {
+ return nei(other, this);
+ }
+
+ /** Test for inequality. */
+ public DoubleMatrix ne(DoubleMatrix other) {
+ return nei(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Test for inequality against a scalar (in-place). */
+ public DoubleMatrix nei(double value, DoubleMatrix result) {
+ ensureResultLength(null, result);
+ for (int i = 0; i < length; i++)
+ result.put(i, get(i) != value ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Test for inequality against a scalar (in-place). */
+ public DoubleMatrix nei(double value) {
+ return nei(value, this);
+ }
+
+ /** test for inequality against a scalar. */
+ public DoubleMatrix ne(double value) {
+ return nei(value, new DoubleMatrix(rows, columns));
+ }
+
+ /** Compute elementwise logical and (in-place). */
+ public DoubleMatrix andi(DoubleMatrix other, DoubleMatrix result) {
+ assertSameLength(other);
+ ensureResultLength(other, result);
+
+ for (int i = 0; i < length; i++)
+ result.put(i, (get(i) != 0.0) & (other.get(i) != 0.0) ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Compute elementwise logical and (in-place). */
+ public DoubleMatrix andi(DoubleMatrix other) {
+ return andi(other, this);
+ }
+
+ /** Compute elementwise logical and. */
+ public DoubleMatrix and(DoubleMatrix other) {
+ return andi(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Compute elementwise logical and against a scalar (in-place). */
+ public DoubleMatrix andi(double value, DoubleMatrix result) {
+ ensureResultLength(null, result);
+ boolean val = (value != 0.0);
+ for (int i = 0; i < length; i++)
+ result.put(i, (get(i) != 0.0) & val ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Compute elementwise logical and against a scalar (in-place). */
+ public DoubleMatrix andi(double value) {
+ return andi(value, this);
+ }
+
+ /** Compute elementwise logical and against a scalar. */
+ public DoubleMatrix and(double value) {
+ return andi(value, new DoubleMatrix(rows, columns));
+ }
+
+ /** Compute elementwise logical or (in-place). */
+ public DoubleMatrix ori(DoubleMatrix other, DoubleMatrix result) {
+ assertSameLength(other);
+ ensureResultLength(other, result);
+
+ for (int i = 0; i < length; i++)
+ result.put(i, (get(i) != 0.0) | (other.get(i) != 0.0) ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Compute elementwise logical or (in-place). */
+ public DoubleMatrix ori(DoubleMatrix other) {
+ return ori(other, this);
+ }
+
+ /** Compute elementwise logical or. */
+ public DoubleMatrix or(DoubleMatrix other) {
+ return ori(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Compute elementwise logical or against a scalar (in-place). */
+ public DoubleMatrix ori(double value, DoubleMatrix result) {
+ ensureResultLength(null, result);
+ boolean val = (value != 0.0);
+ for (int i = 0; i < length; i++)
+ result.put(i, (get(i) != 0.0) | val ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Compute elementwise logical or against a scalar (in-place). */
+ public DoubleMatrix ori(double value) {
+ return ori(value, this);
+ }
+
+ /** Compute elementwise logical or against a scalar. */
+ public DoubleMatrix or(double value) {
+ return ori(value, new DoubleMatrix(rows, columns));
+ }
+
+ /** Compute elementwise logical xor (in-place). */
+ public DoubleMatrix xori(DoubleMatrix other, DoubleMatrix result) {
+ assertSameLength(other);
+ ensureResultLength(other, result);
+
+ for (int i = 0; i < length; i++)
+ result.put(i, (get(i) != 0.0) ^ (other.get(i) != 0.0) ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Compute elementwise logical xor (in-place). */
+ public DoubleMatrix xori(DoubleMatrix other) {
+ return xori(other, this);
+ }
+
+ /** Compute elementwise logical xor. */
+ public DoubleMatrix xor(DoubleMatrix other) {
+ return xori(other, new DoubleMatrix(rows, columns));
+ }
+
+ /** Compute elementwise logical xor against a scalar (in-place). */
+ public DoubleMatrix xori(double value, DoubleMatrix result) {
+ ensureResultLength(null, result);
+ boolean val = (value != 0.0);
+ for (int i = 0; i < length; i++)
+ result.put(i, (get(i) != 0.0) ^ val ? 1.0 : 0.0);
+ return result;
+ }
+
+ /** Compute elementwise logical xor against a scalar (in-place). */
+ public DoubleMatrix xori(double value) {
+ return xori(value, this);
+ }
+
+ /** Compute elementwise logical xor against a scalar. */
+ public DoubleMatrix xor(double value) {
+ return xori(value, new DoubleMatrix(rows, columns));
+ }
+//RJPP-END--------------------------------------------------------------
}

0 comments on commit 3370088

Please sign in to comment.