[jblas] 15/24: Imported Upstream version 1.2.0

Tony Mancill tmancill at moszumanska.debian.org
Sun Jan 5 05:45:59 UTC 2014


This is an automated email from the git hooks/post-receive script.

tmancill pushed a commit to branch master
in repository jblas.

commit f258815e263c452472f7709eaa4864070acea367
Author: tony mancill <tmancill at debian.org>
Date:   Tue Dec 31 15:19:23 2013 -0800

    Imported Upstream version 1.2.0
---
 .classpath                                         |    9 -
 .project                                           |   23 -
 AUTHORS                                            |    4 +-
 BUILDING_ATLAS                                     |   82 +-
 INSTALL                                            |   24 +-
 Makefile                                           |   41 +-
 README                                             |   16 +-
 RELEASE_NOTES                                      |   26 +
 build.xml                                          |   47 +-
 config/config_cc.rb                                |   20 +-
 config/config_fortran.rb                           |    6 +-
 config/config_os_arch.rb                           |    2 +-
 config/config_tools.rb                             |   12 +-
 config/configure.rb                                |    1 +
 config/lib_helpers.rb                              |    2 +-
 config/{config_tools.rb => windows.rb}             |   27 +-
 fortranwrapper.dump                                |  Bin 21305 -> 22347 bytes
 nbproject/ide-file-targets.xml                     |   43 -
 nbproject/project.xml                              |  199 -
 pom.xml                                            |   67 +
 scripts/fortran/java.rb                            |    8 +-
 scripts/fortranwrapper.rb                          |    5 +-
 src/main/c/NativeBlas.c                            | 4340 ++++++++++++++++++++
 {native => src/main/c}/jblas_arch_flavor.c         |    0
 src/main/c/org_jblas_NativeBlas.h                  |  640 +++
 src/main/c/org_jblas_util_ArchFlavor.h             |   30 +
 src/{ => main/java}/org/jblas/ComplexDouble.java   |    0
 .../java}/org/jblas/ComplexDoubleMatrix.java       |    2 +-
 src/{ => main/java}/org/jblas/ComplexFloat.java    |    0
 .../java}/org/jblas/ComplexFloatMatrix.java        |    2 +-
 .../java}/org/jblas/ConvertsToDoubleMatrix.java    |    0
 .../java}/org/jblas/ConvertsToFloatMatrix.java     |    0
 src/{ => main/java}/org/jblas/Decompose.java       |    0
 src/{ => main/java}/org/jblas/DoubleFunction.java  |    0
 src/{ => main/java}/org/jblas/DoubleMatrix.java    |    5 +-
 src/main/java/org/jblas/Eigen.java                 |  271 ++
 src/{ => main/java}/org/jblas/FloatFunction.java   |    0
 src/{ => main/java}/org/jblas/FloatMatrix.java     |    5 +-
 src/{ => main/java}/org/jblas/Geometry.java        |    0
 src/{ => main/java}/org/jblas/JavaBlas.java        |    0
 src/{ => main/java}/org/jblas/MatrixFunctions.java |    0
 src/{ => main/java}/org/jblas/NativeBlas.java      |   32 +
 src/main/java/org/jblas/SimpleBlas.java            |  732 ++++
 src/{ => main/java}/org/jblas/Singular.java        |    0
 src/{ => main/java}/org/jblas/Solve.java           |    0
 src/{ => main/java}/org/jblas/Trigonometry.java    |    0
 .../ATLASDoubleMultiplicationBenchmark.java        |    0
 .../ATLASFloatMultiplicationBenchmark.java         |    0
 .../java}/org/jblas/benchmark/Benchmark.java       |    0
 .../java}/org/jblas/benchmark/BenchmarkResult.java |    0
 .../JavaDoubleMultiplicationBenchmark.java         |    0
 .../JavaFloatMultiplicationBenchmark.java          |    0
 src/{ => main/java}/org/jblas/benchmark/Main.java  |    0
 src/{ => main/java}/org/jblas/benchmark/Timer.java |    0
 .../java}/org/jblas/benchmark/package-info.java    |    0
 .../jblas/exceptions/LapackArgumentException.java  |    0
 .../exceptions/LapackConvergenceException.java     |    0
 .../org/jblas/exceptions/LapackException.java      |    0
 .../exceptions/LapackPositivityException.java      |    0
 .../exceptions/LapackSingularityException.java     |    0
 .../java}/org/jblas/exceptions/SizeException.java  |    0
 .../java}/org/jblas/exceptions/package-info.java   |    0
 src/{ => main/java}/org/jblas/package-info.java    |    0
 src/{ => main/java}/org/jblas/ranges/AllRange.java |    0
 .../java}/org/jblas/ranges/IndicesRange.java       |    0
 .../java}/org/jblas/ranges/IntervalRange.java      |    0
 .../java}/org/jblas/ranges/PointRange.java         |    0
 src/{ => main/java}/org/jblas/ranges/Range.java    |    0
 .../java}/org/jblas/ranges/RangeUtils.java         |    0
 .../java}/org/jblas/ranges/package-info.java       |    0
 src/{ => main/java}/org/jblas/util/ArchFlavor.java |    6 +-
 src/{ => main/java}/org/jblas/util/Functions.java  |    0
 .../java}/org/jblas/util/LibraryLoader.java        |    0
 src/{ => main/java}/org/jblas/util/Logger.java     |    0
 .../java}/org/jblas/util/Permutations.java         |    0
 .../java}/org/jblas/util/SanityChecks.java         |   11 +-
 .../java}/org/jblas/util/package-info.java         |    0
 src/{ => main/java}/overview.html                  |    0
 src/{ => main/java}/overview.textile               |    0
 .../lib/static/Linux/amd64/libjblas_arch_flavor.so |  Bin 0 -> 7811 bytes
 .../lib/static/Linux/amd64/sse2/libjblas.so        |  Bin 0 -> 6240026 bytes
 .../lib/static/Linux/amd64/sse3/libjblas.so        |  Bin 0 -> 4751359 bytes
 .../lib/static/Linux/i386/libjblas_arch_flavor.so  |  Bin 0 -> 5413 bytes
 .../lib/static/Linux/i386/sse2/libjblas.so         |  Bin 0 -> 5353071 bytes
 .../lib/static/Linux/i386/sse3/libjblas.so         |  Bin 0 -> 5578487 bytes
 .../Mac OS X/x86_64/libjblas_arch_flavor.jnilib    |  Bin 0 -> 8496 bytes
 .../static/Mac OS X/x86_64/sse3/libjblas.jnilib    |  Bin 0 -> 7760504 bytes
 .../resources/lib/static/Windows/amd64/jblas.dll   |  Bin 0 -> 5116529 bytes
 .../lib/static/Windows/amd64/jblas_arch_flavor.dll |  Bin 0 -> 121365 bytes
 .../lib/static/Windows/x86/jblas_arch_flavor.dll   |  Bin 0 -> 38184 bytes
 .../lib/static/Windows/x86/sse2/jblas.dll          |  Bin 0 -> 5313362 bytes
 .../lib/static/Windows/x86/sse3/jblas.dll          |  Bin 0 -> 5478336 bytes
 src/org/jblas/Eigen.java                           |  190 -
 src/org/jblas/SimpleBlas.java                      |  653 ---
 .../java}/org/jblas/ComplexDoubleMatrixTest.java   |    0
 .../test/java}/org/jblas/SimpleBlasTest.java       |    0
 .../test/java}/org/jblas/TestBlasDouble.java       |    0
 .../java}/org/jblas/TestBlasDoubleComplex.java     |    0
 .../test/java}/org/jblas/TestBlasFloat.java        |    0
 .../test/java}/org/jblas/TestComplexFloat.java     |    0
 .../test/java}/org/jblas/TestDoubleMatrix.java     |    0
 {test => src/test/java}/org/jblas/TestEigen.java   |   39 +-
 .../test/java/org/jblas/TestFloatMatrix.java       |  266 +-
 .../test/java}/org/jblas/TestGeometry.java         |    0
 test/org/jblas/TestSolve.java                      |   20 +-
 105 files changed, 6530 insertions(+), 1378 deletions(-)

diff --git a/.classpath b/.classpath
deleted file mode 100644
index 5b86d24..0000000
--- a/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="src" path="test"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/.project b/.project
deleted file mode 100644
index fb01a39..0000000
--- a/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>Java-Blas</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.rubypeople.rdt.core.rubybuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.rubypeople.rdt.core.rubynature</nature>
-	</natures>
-</projectDescription>
diff --git a/AUTHORS b/AUTHORS
index d8eb26c..dcadd5e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -5,4 +5,6 @@ Mikio L. Braun
 Additional Programming and Contributions:
 
 Johannes Schaback
-Jan Saputra Müller
\ No newline at end of file
+Jan Saputra Müller (exponential matrix multiplication, decomposition)
+Matthias L. Jugel (packaging)
+Nicolas Oury (generalized eigenvectors)
\ No newline at end of file
diff --git a/BUILDING_ATLAS b/BUILDING_ATLAS
index ecd1070..32dc021 100644
--- a/BUILDING_ATLAS
+++ b/BUILDING_ATLAS
@@ -42,27 +42,29 @@ git clone git://github.com/mikiobraun/jblas.git
 
 The general steps are as follows:
 
-* Compile lapack. Lapack uses blas for its low-level computations. ATLAS also
-  implements a subset of Lapack, but not all routines. But you can build ATLAS
-  to include the Lapack routines it does not implement, and this is what we're
-  going to do.
+* Compile lapack. Lapack uses blas for its low-level
+  computations. ATLAS also implements a subset of Lapack, but not all
+  routines. But you can build ATLAS to include the Lapack routines it
+  does not implement, and this is what we're going to do.
 
 * Compile ATLAS.
 
 * Compile the native part of jblas with "make".
 
-* Compile the java part of jblas with "ant".
+* Compile the java part of jblas with "ant" or maven.
 
-The ATLAS build process is a bit, well, unusual, coming with compiled (not scripted)
-configuration scripts. ATLAS has prebuilt configurations which result in much
-faster compilation times. If it doesn't find such a profile for your computer,
-it will perform a large number of timing experiments to find the best combination
-(hence the name "Automatically Tuned...").
+The ATLAS build process is a bit, well, unusual, coming with compiled
+(not scripted) configuration scripts. ATLAS has prebuilt
+configurations which result in much faster compilation times. If it
+doesn't find such a profile for your computer, it will perform a large
+number of timing experiments to find the best combination (hence the
+name "Automatically Tuned...").
 
-Finally, some older processors don't support the SSE3 command set. Some tweaking
-is necessary to compile ATLAS for SSE2, namely configuring as for SSE3, and
-then going into the file "Make.inc", and replacing SSE2 by SSE3 or removing -DATL_SSE3
-from the compiler directives.
+Finally, some older processors don't support the SSE3 command
+set. Some tweaking is necessary to compile ATLAS for SSE2, namely
+configuring as for SSE3, and then going into the file "Make.inc", and
+replacing SSE2 by SSE3 or removing -DATL_SSE3 from the compiler
+directives.
 
 For reference, here is a list of the main ATLAS options.
 
@@ -129,7 +131,8 @@ ATLAS Operating System Options: (-O)
 LAPACK
 ------
 
-Copy make.inc.LINUX from INSTALL directory, update options in the file like this:
+Copy make.inc.LINUX from INSTALL directory, update options in the file
+like this:
 
 FORTRAN  = gfortran 
 OPTS     = -O2 -fPIC
@@ -218,15 +221,17 @@ It's important to set the 32bit flag. Otherwise, it seems to construct
 5. Windows XP (32bit)
 =====================
 
-I'm describing here using cygwin. For some reason, the gcc4 version in cygwin
-does not support compiling to mingw, but using the cygwin version leads
-to some address spaces clashes with Java (at least, the last time I checked),
-leading to a crash as soon as the cygwin compiled code is loaded.
+I'm describing here using cygwin. For some reason, the gcc4 version in
+cygwin does not support compiling to mingw, but using the cygwin
+version leads to some address spaces clashes with Java (at least, the
+last time I checked), leading to a crash as soon as the cygwin
+compiled code is loaded.
 
-What all of this means is that you should use the old gcc3 "legacy" compilers.
+What all of this means is that you should use the old gcc3 "legacy"
+compilers.
 
-Also watch out for directory names with spaces in them, ATLAS does not like
-them.
+Also watch out for directory names with spaces in them, ATLAS does not
+like them.
 
 LAPACK
 ------
@@ -245,8 +250,31 @@ compiler explicitly to "g77" (and the bit numbers to 32):
 64-bit
 ------
 
-Unfortunately, there is no support for 64bit under Windows right now,
-mainly because there is no 64bit mingw compiler in cygwin. There
-exists the mingw-w64 bit project
-(http://sourceforge.net/projects/mingw-w64/), but I didn't managed to
-compile ATLAS using those.
+Unfortunately, it is currently not possible to compile ATLAS for 64bit
+under windows, mainly because cygwin is 32bit. There exists the
+ming-w64 bit project (http://sourceforge.net/projects/mingw-w64/),
+which provides 64bit compiler for the MINGW environment (a subset of
+the UNIX- like environment cygwin provides, unfortunately insufficient
+to build ATLAS).
+
+What you can do, though,
+
+Pure LAPACK-build on Windows 64 bit
+-----------------------------------
+
+Install the x86_64-w64-mingw32 compilers (just about everything except
+for ada and objective C) ;)
+
+In order to run fortran files, you might need to put
+
+x86_64-w64-mingw32/sys-root/mingw/bin/
+
+into your PATH.
+
+Then, go into lapack-lite, and edit make.inc such that gfortran is
+replaced by x86_64-w64-mingw32-gfortran everywhere. You should also
+include the -funroll-all-loops -O3 options.
+
+Compile using "make -k blaslib lapacklib" as usual, and rename the
+results to libblas.a and liblapack.a. Then, do a normal lapack build.
+
diff --git a/INSTALL b/INSTALL
index 26e6ce3..f4840ac 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,6 @@
 INSTALL Guide 
 
+Version 1.2.0, January 7, 2011
 Version 1.0, December 22, 2009
 Version 0.3, September 17, 2009
 Version 0.2, May 8, 2009
@@ -22,6 +23,9 @@ If you are only adding code on the Java side, then you can work with
 the supplied build.xml ant script. Simply type "ant jar" to compile
 the new jar file.
 
+Starting with version 1.2.0, you can also use maven to compile the project.
+Both alternatives exist in parallel.
+
 If you want to access further functions from LAPACK, you need to
 recompile the native part. This procedure is a bit more involved, see
 below.
@@ -33,8 +37,12 @@ COMPILING JBLAS (JAVA PART)
 Prerequisites: 
   - java JDK
   - ant
+  - maven
   - ruby
 
+ANT BUILD
+---------
+
 Running "ant clean jar" should do the job ;)
 
 "ant jar" collects all static JNI libraries. Other build targets are:
@@ -54,14 +62,20 @@ Running "ant clean jar" should do the job ;)
   Build a jar file without the JNI and ATLAS libraries. Both must be
   installed in the usual library locations.
 
+MAVEN BUILD
+-----------
+
+Just the usual "mvn clean install" builds everything and installs the jar
+file in your local repository.
 
 INSTALLING JBLAS
+----------------
 
-1. Add "jblas-1.0.jar" to your CLASSPATH
+1. Add "jblas-1.2.0.jar" to your CLASSPATH
 
 2. By default, the dynamic libraries are extracted from the jar file
    to the default temporary directory and loaded from there. If you
-   don't want to do this, extract the dynamic library from jblas-0.2.jar
+   don't want to do this, extract the dynamic library from jblas-1.2.0.jar
    and copy it somewhere where it can be found.
 
    For Linux, use LD_LIBRARY_PATH, for Windows, PATH
@@ -130,6 +144,12 @@ The configure script understands the following options:
    Searches for static libraries only. Resulting jblas will not depend on
    shared LAPACK/BLAS/ATLAS libraries. Default for Windows XP.
 
+--ptatlas
+   Uses multithreaded versions of the ATLAS libraries. AFAIK, these should
+   be compiled on the target computer to have the right number of threads.
+   This means you have to recompile ATLAS, but it is certainly worth
+   the effort, performance improvements are really huge!
+
 --help
    print help
 
diff --git a/Makefile b/Makefile
index 19e07cd..c888190 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ## --- END LICENSE BLOCK ---
 
-VERSION=1.1.1
+VERSION=1.2.0
 
 ######################################################################
 #
@@ -54,11 +54,18 @@ PACKAGE=org.jblas
 # generate path from package name
 PACKAGE_PATH=$(subst .,/,$(PACKAGE))
 
-LIB_PATH=native-libs/$(LINKAGE_TYPE)/$(OS_NAME)/$(OS_ARCH)
-FULL_LIB_PATH=native-libs/$(LINKAGE_TYPE)/$(OS_NAME)/$(OS_ARCH_WITH_FLAVOR)
+SRC=src/main
+SRC_JAVA=$(SRC)/java
+SRC_C=$(SRC)/c
+RESOURCES=$(SRC)/resources
 
-GENERATED_SOURCES=src/$(PACKAGE_PATH)/NativeBlas.java native/NativeBlas.c
-GENERATED_HEADERS=include/org_jblas_NativeBlas.h include/org_jblas_util_ArchFlavor.h
+TARGET_C=target/c
+
+LIB_PATH=$(RESOURCES)/lib/$(LINKAGE_TYPE)/$(OS_NAME)/$(OS_ARCH)
+FULL_LIB_PATH=$(RESOURCES)/lib/$(LINKAGE_TYPE)/$(OS_NAME)/$(OS_ARCH_WITH_FLAVOR)
+
+GENERATED_SOURCES=$(SRC_JAVA)/$(PACKAGE_PATH)/NativeBlas.java $(SRC_C)/NativeBlas.c
+GENERATED_HEADERS=$(SRC_C)/org_jblas_NativeBlas.h $(SRC_C)/org_jblas_util_ArchFlavor.h
 SHARED_LIBS=$(FULL_LIB_PATH)/$(LIB)jblas.$(SO) $(LIB_PATH)/$(LIB)jblas_arch_flavor.$(SO) 
 
 #######################################################################
@@ -91,7 +98,7 @@ generate-wrapper: $(GENERATED_SOURCES) $(GENERATED_HEADERS)
 
 # Clean all object files
 clean:
-	rm -f native/*.o native/*.$(SO) $(LIB_PATH)/*.$(SO) $(FULL_LIB_PATH)/*.$(SO) src/$(PACKAGE_PATH)/NativeBlas.java generated-sources
+	rm -f native/*.o native/*.$(SO) $(LIB_PATH)/*.$(SO) $(FULL_LIB_PATH)/*.$(SO) $(SRC_JAVA)/$(PACKAGE_PATH)/NativeBlas.java $(SRC_C)/NativeBlas.c generated-sources
 
 # Full clean, including information extracted from the fortranwrappers.
 # You will need the original fortran sources in order to rebuild
@@ -110,7 +117,7 @@ endif
 generated-sources: \
   scripts/fortranwrapper.rb scripts/fortran/types.rb \
   scripts/fortran/java.rb scripts/java-class.java scripts/java-impl.c \
-  src/org/jblas/util/ArchFlavor.java #src/org/jblas/NativeBlas.java 
+  $(SRC_JAVA)/org/jblas/util/ArchFlavor.java #src/org/jblas/NativeBlas.java
 	$(RUBY) scripts/fortranwrapper.rb --complexcc $(CCC) $(PACKAGE) NativeBlas \
 	$(BLAS)/[sdcz]copy.f \
 	$(BLAS)/[sdcz]swap.f \
@@ -132,24 +139,28 @@ generated-sources: \
 	$(LAPACK)/[sdcz]geev.f \
 	$(LAPACK)/[sd]getrf.f \
 	$(LAPACK)/[sd]potrf.f \
-	$(LAPACK)/[sdcz]gesvd.f
+	$(LAPACK)/[sdcz]gesvd.f \
+	$(LAPACK)/[sd]sygvd.f 
 	ant javah
 	touch $@
 
-native/NativeBlas.c: generated-sources
+$(SRC_C)/NativeBlas.c: generated-sources
+
+$(TARGET_C):
+	mkdir $(TARGET_C)
 
-native/NativeBlas.o: native/NativeBlas.c
-	$(CC) $(CFLAGS) $(INCDIRS) -c native/NativeBlas.c -o $@
+$(TARGET_C)/NativeBlas.o: $(SRC_C)/NativeBlas.c $(TARGET_C)
+	$(CC) $(CFLAGS) $(INCDIRS) -c $(SRC_C)/NativeBlas.c -o $@
 
-native/jblas_arch_flavor.o: generated-sources
-	$(CC) $(CFLAGS) $(INCDIRS) -c native/jblas_arch_flavor.c -o $@
+$(TARGET_C)/jblas_arch_flavor.o: generated-sources
+	$(CC) $(CFLAGS) $(INCDIRS) -c $(SRC_C)/jblas_arch_flavor.c -o $@
 
 # Move the compile library to the machine specific directory.
-$(FULL_LIB_PATH)/$(LIB)jblas.$(SO) : native/NativeBlas.$(SO)
+$(FULL_LIB_PATH)/$(LIB)jblas.$(SO) : $(TARGET_C)/NativeBlas.$(SO)
 	mkdir -p $(FULL_LIB_PATH)
 	mv "$<" "$@"
 
-$(LIB_PATH)/$(LIB)jblas_arch_flavor.$(SO): native/jblas_arch_flavor.$(SO)
+$(LIB_PATH)/$(LIB)jblas_arch_flavor.$(SO): $(SRC_C)/jblas_arch_flavor.$(SO)
 	mkdir -p $(LIB_PATH)
 	mv "$<" "$@"
 
diff --git a/README b/README
index aaffcba..d1b8cc9 100644
--- a/README
+++ b/README
@@ -1,6 +1,7 @@
 jblas is a matrix library for Java which uses existing high
 performance BLAS and LAPACK libraries like ATLAS.
 
+Version 1.2.0, January 7, 2011
 Version 1.1.1
 Version 1.1, August 16, 2010
 Version 1.0.2, February 26, 2010
@@ -16,8 +17,8 @@ Homepage: http://jblas.org
 
 INSTALL
 
-In principle, all you need is the jblas-1.1,jar in your
-classpath. jblas-1.1.jar will then automagically extract your platform
+In principle, all you need is the jblas-1.2.0,jar in your
+classpath. jblas-1.2.0.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).
@@ -39,22 +40,23 @@ with either plain lapack, or ATLAS
 sources for BLAS and LAPACK, available, for example from
 http://www.netlib.org/lapack/lapack-lite-3.1.1.tgz.
 
-If you still want to build the source your own, see INSTALL for further
-details.
+If you still want to build the source your own, see INSTALL for
+further details.
 
 
 HOW TO GET STARTED
 
-Have a look at javadoc/index.html and javadoc/org/jblas/DoubleMatrix.html
+Have a look at javadoc/index.html and
+javadoc/org/jblas/DoubleMatrix.html
 
 If you want to validate your installation and get some performance
-numbers, try "java -server -jar jblas-1.1.jar", or drop the server
+numbers, try "java -server -jar jblas-1.2.0.jar", or drop the server
 in case, you only have the "client" JVM installed.
 
 
 LICENSE
 
-jblas is distributed under a BSD-style license. See the file LICENSE
+jblas is distributed under a BSD-style license. See the file COPYING
 for more information.
 
 
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 0e627c6..3a9949a 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -1,3 +1,29 @@
+Release 1.2.0 - January 7, 2011
+
+- Added Generalized Eigenvalues for symmetric matrices (which you
+  need, for example, for Canoncial Correlation Analysis). See
+  org.jblas.Eigen.
+
+- Added pure-LAPACK build to Windows 64. Not as nearly as fast as
+  ATLAS, but still 50% over pure Java implementation (for example, for
+  DGEMM).
+
+- Changed build system to maven. Actually, the build.xml from the ant
+  file still exists and can also be used, but now you also have a
+  pom.xml.
+
+- As a side effect of the change to maven, test suites are now
+  actually run during the build ;)
+
+Some bugs:
+
+- Fortran functions returning floats (e.g. SDOT) returned 0.0. Fixed
+  now.
+
+- Bug in some complex numbers routines.
+
+---------------------------------------------------------------------
+
 Release 1.1.1
 
 Mostly bug fixes
diff --git a/build.xml b/build.xml
index f02e923..7ba2f9a 100644
--- a/build.xml
+++ b/build.xml
@@ -41,15 +41,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
     <!-- Define directories -->
 
-    <property name="version" value="1.1.1" />
-    <property name="src" value="${basedir}/src" />
-    <property name="test" value="${basedir}/test" />
-    <property name="bin" value="${basedir}/bin" />
-    <property name="native-libs" value="${basedir}/native-libs" />
+    <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" />
+    <property name="native-libs" value="${basedir}/src/main/resources/lib" />
     <property name="doc" value="${basedir}/javadoc" />
-    <property name="jar" value="${basedir}/jblas.jar" />
-    <property name="include" value="${basedir}/include" />
-    <property name="native" value="${basedir}/native" />
+    <property name="jar" value="${basedir}/target/jblas-${version}.jar" />
+    <property name="include" value="${basedir}/src/main/c" />
+    <property name="native" value="${basedir}/src/main/c" />
     <property name="external" value="${basedir}/external" />
     <property name="scripts" value="${basedir}/scripts" />
     <property name="pkgbase" value="org.jblas" />
@@ -58,7 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
     <macrodef name="class-to-float" description="generate a float version of a class">
         <attribute name="class"/>
-        <attribute name="path" default="src"/>
+        <attribute name="path" default="${src}"/>
         <sequential>
             <echo message="Generating float version of @{class}"/>
             <exec executable="ruby">
@@ -71,7 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         <sequential>
             <echo message="Add float versions to class @{class}"/>
             <exec executable="ruby">
-                <arg line="scripts/static_class_to_float.rb src @{class}"/>
+                <arg line="scripts/static_class_to_float.rb ${src} @{class}"/>
             </exec>
         </sequential>
     </macrodef>
@@ -100,13 +100,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
             </jar>
         </sequential>
     </macrodef>
+    <macrodef name="rb-macro" description="Run the ruby macro precessor.">
+        <attribute name="definitions" />
+        <attribute name="file" />
+        <sequential>
+            <exec executable="ruby">
+                <arg line="-I templates scripts/macro.rb templates/@{definitions}.rb templates/@{file} src/@{file}" />
+            </exec>
+        </sequential>
+    </macrodef>
 
     <!-- Organizational targets -->
 
     <target name="clean" description="clean generated files">
         <delete dir="${doc}" />
         <delete dir="${bin}" />
-        <delete dir="${include}" />
     </target>
     <target name="clean-jars" description="delete all jar files">
         <delete>
@@ -115,7 +123,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     </target>
     <target name="prepare" description="create directories needed for compilation">
         <mkdir dir="${bin}" />
-        <mkdir dir="${include}" />
     </target>
     <target name="compile" depends="prepare,generate-float" description="compile java code">
         <javac destdir="${bin}" encoding="utf-8" source="1.5" debug="on" compiler="javac1.5" target="1.5" fork="yes" nowarn="yes">
@@ -153,8 +160,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         <class-to-float class="${pkgbase}.DoubleMatrix"/>
         <class-to-float class="${pkgbase}.DoubleFunction"/>
         <class-to-float class="${pkgbase}.ComplexDouble"/>
-        <class-to-float path="test" class="${pkgbase}.TestDoubleMatrix"/>
-        <class-to-float path="test" class="${pkgbase}.TestBlasDouble"/>
+        <class-to-float path="${test}" class="${pkgbase}.TestDoubleMatrix"/>
+        <class-to-float path="${test}" class="${pkgbase}.TestBlasDouble"/>
         <class-to-float class="${pkgbase}.ComplexDoubleMatrix"/>
         <static-class-to-float class="${pkgbase}.SimpleBlas"/>
         <static-class-to-float class="${pkgbase}.Solve"/>
@@ -166,12 +173,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         <!--<static-class-to-float class="${pkgbase}.Decompose"/>-->
     </target>
     <target name="preprocess" description="run the ruby preprocessor on necessary files">
-        <rjpp file="src/org/jblas/DoubleMatrix.java"/>
-        <rjpp file="test/org/jblas/TestDoubleMatrix.java"/>
-        <rjpp file="src/org/jblas/MatrixFunctions.java"/>
-        <rjpp file="src/org/jblas/ComplexDoubleMatrix.java"/>
+        <rjpp file="${src}/org/jblas/DoubleMatrix.java"/>
+        <rjpp file="${test}/org/jblas/TestDoubleMatrix.java"/>
+        <rjpp file="${src}/org/jblas/MatrixFunctions.java"/>
+        <rjpp file="${src}/org/jblas/ComplexDoubleMatrix.java"/>
+    </target>
+    <target name="templates" description="Generate code from templates">
+        <rb-macro definitions="general" file="org/jblas/Matrix.java" />
     </target>
 
+
     <!-- jar files -->
 
     <target name="dynamic-lean-jar" depends="compile" description="create jblas.jar (local system, dynamic)">
diff --git a/config/config_cc.rb b/config/config_cc.rb
index 7343bad..6871149 100644
--- a/config/config_cc.rb
+++ b/config/config_cc.rb
@@ -70,9 +70,22 @@ RUBY=ruby
 LDFLAGS += -G
 EOS
   when 'Windows'
-    Path.check_cmd('gcc', 'make', 'ld')
-    Path.check_cmd('cygpath')
-    Config::CONFIG << <<EOS
+    if w64build?
+      Path.check_cmd(W64_PREFIX + 'gcc', 'make', W64_PREFIX + 'ld')
+      Path.check_cmd('cygpath')
+      Config::CONFIG << <<EOS
+CC = #{W64_PREFIX}gcc
+CFLAGS = -ggdb -D__int64='long long'
+INCDIRS += -I"#{dir java_home}/include" -I"#{dir java_home}/include/win32" -Iinclude
+LDFLAGS += -shared -Wl,--add-stdcall-alias
+SO = dll
+LIB =
+RUBY = ruby
+EOS
+    else
+      Path.check_cmd('gcc', 'make', 'ld')
+      Path.check_cmd('cygpath')
+      Config::CONFIG << <<EOS
 CC = gcc
 CFLAGS = -ggdb -D__int64='long long'
 INCDIRS += -I"#{dir java_home}/include" -I"#{dir java_home}/include/win32" -Iinclude
@@ -81,6 +94,7 @@ SO = dll
 LIB =
 RUBY = ruby
 EOS
+    end
   when 'Mac\ OS\ X'
     Path.check_cmd('gcc-mp-4.3', 'make')
     Config::CONFIG << <<EOS
diff --git a/config/config_fortran.rb b/config/config_fortran.rb
index d3c1df0..69b7053 100644
--- a/config/config_fortran.rb
+++ b/config/config_fortran.rb
@@ -43,7 +43,7 @@ include Path
 configure :fortran => ['F77', 'LD']
 
 desc 'deciding whether to use g77 or gfortran'
-configure 'F77', 'LD' => [:os_arch, :cc] do
+configure 'F77', 'LD' => ['OS_NAME', 'CC'] do
   #unless ENV['CC'].nil?
   #  CONFIG['CC'] = ENV['CC']
   #  return
@@ -53,6 +53,10 @@ configure 'F77', 'LD' => [:os_arch, :cc] do
     CONFIG['LD'] = CONFIG['CC']
     CONFIG['F77'] = 'gfortran-mp-4.3'
     CONFIG['CCC'] = 'c99'
+  elsif CONFIG['OS_NAME'] == 'Windows' and CONFIG['OS_ARCH'] == 'amd64'
+    CONFIG['LD'] = W64_PREFIX + 'gfortran'
+    CONFIG['F77'] = W64_PREFIX + 'gfortran'
+    CONFIG['CCC'] = 'c99'
   else
     g77 = Path.where('g77')
     gfortran = Path.where('gfortran')
diff --git a/config/config_os_arch.rb b/config/config_os_arch.rb
index 975084d..1e9e2ec 100644
--- a/config/config_os_arch.rb
+++ b/config/config_os_arch.rb
@@ -81,7 +81,7 @@ configure 'ARCH_FLAVOR' => 'OS_ARCH' do
     arch_flavor = ''
   end
 
-  if arch_flavor.empty?
+  if arch_flavor.empty? or arch_flavor == 'none'
     CONFIG['OS_ARCH_WITH_FLAVOR'] = CONFIG['OS_ARCH']
   else
     CONFIG['OS_ARCH_WITH_FLAVOR'] = CONFIG['OS_ARCH'] + File::SEPARATOR + arch_flavor
diff --git a/config/config_tools.rb b/config/config_tools.rb
index 24a71ae..8f87f8a 100644
--- a/config/config_tools.rb
+++ b/config/config_tools.rb
@@ -35,6 +35,7 @@
 require 'config/config'
 require 'config/path'
 require 'config/config_os_arch'
+require 'config/windows'
 
 include Config
 include Path
@@ -42,8 +43,15 @@ include Path
 configure :tools => ['FOUND_NM', 'FOUND_CYGPATH']
 
 desc 'looking for nm'
-configure 'FOUND_NM' do
-  check_cmd 'nm'
+configure 'FOUND_NM' => ['OS_NAME', 'OS_ARCH'] do
+  if CONFIG['OS_NAME'] == "Windows" and CONFIG['OS_ARCH'] == 'amd64'
+    puts "Looking for 64bit toolchain"
+    check_cmd(W64_PREFIX + 'nm')
+    CONFIG['NM'] = W64_PREFIX + 'nm'
+  else
+    check_cmd 'nm'
+    CONFIG['NM'] = 'nm'
+  end
   CONFIG['FOUND_NM'] = true
   ok
 end
diff --git a/config/configure.rb b/config/configure.rb
index 06977bb..5234eab 100644
--- a/config/configure.rb
+++ b/config/configure.rb
@@ -80,6 +80,7 @@ options summary:
                            dynamically loaded jblas library which does
                            not depend on lapack or atlas libraries. 
                            (default for Windows!)
+  --ptatlas                Link against multithreaded versions of ATLAS libraries
   --arch-flavor=...        Set architectural flavor (e.g. --arch-flavor=sse2)
 EOS
 
diff --git a/config/lib_helpers.rb b/config/lib_helpers.rb
index 6a3812e..cde1a7a 100644
--- a/config/lib_helpers.rb
+++ b/config/lib_helpers.rb
@@ -64,7 +64,7 @@ module LibHelpers
   # returns an array of the symbols defined in the library +fn+.
   def libsyms(fn)
     nmopt = File.extname(fn) == '.so' ? '-D' : ''
-    %x(nm -p #{nmopt} #{fn.escape}).grep(/ T _?([a-zA-Z0-9_]+)/) {|m| $1}
+    %x(#{Config::CONFIG['NM']} -p #{nmopt} #{fn.escape}).grep(/ T _?([a-zA-Z0-9_]+)/) {|m| $1}
   end
 
   def locate_lib(libpath, name, symbol=nil)
diff --git a/config/config_tools.rb b/config/windows.rb
old mode 100644
new mode 100755
similarity index 78%
copy from config/config_tools.rb
copy to config/windows.rb
index 24a71ae..999e54f
--- a/config/config_tools.rb
+++ b/config/windows.rb
@@ -33,30 +33,9 @@
 ## --- END LICENSE BLOCK ---
 
 require 'config/config'
-require 'config/path'
-require 'config/config_os_arch'
 
-include Config
-include Path
+W64_PREFIX = 'x86_64-w64-mingw32-'
 
-configure :tools => ['FOUND_NM', 'FOUND_CYGPATH']
-
-desc 'looking for nm'
-configure 'FOUND_NM' do
-  check_cmd 'nm'
-  CONFIG['FOUND_NM'] = true
-  ok
-end
-
-configure 'FOUND_CYGPATH' => 'OS_NAME' do
-  if CONFIG['OS_NAME'] == 'Windows'
-    msg 'checking for cygpath' do
-      check_cmd 'cygpath'
-      CONFIG['FOUND_CGYPATH'] = true
-    end
-  end
+def w64build?
+  Config::CONFIG['OS_NAME'] == 'Windows' and Config::CONFIG['OS_ARCH'] == 'amd64'
 end
-
-if __FILE__ == $0
-  ConfigureTask.run :tools
-end
\ No newline at end of file
diff --git a/fortranwrapper.dump b/fortranwrapper.dump
index 9a5b536..5444084 100644
Binary files a/fortranwrapper.dump and b/fortranwrapper.dump differ
diff --git a/nbproject/ide-file-targets.xml b/nbproject/ide-file-targets.xml
deleted file mode 100644
index 0dcdfda..0000000
--- a/nbproject/ide-file-targets.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project basedir=".." name="jBLAS-IDE">
-    <import file="../build.xml"/>
-    <!-- TODO: edit the following target according to your needs -->
-    <!-- (more info: http://www.netbeans.org/kb/41/freeform-config.html#runsingle) -->
-    <target name="test-selected-file-in-test-old">
-        <fail unless="run.class">Must set property 'run.class'</fail>
-        <junit classname="${run.class}" failonerror="true" fork="true">
-            <classpath>
-                <pathelement path="external/junit.jar:bin"/>
-            </classpath>
-        </junit>
-    </target>
-    <target depends="compile,compileNative" name="test-selected-file-in-test">
-        <mkdir dir="test-results"/>
-        <junit errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
-            <test name="${run.class}" todir="test-results"/>
-            <classpath path="${bin}:external/junit.jar"/>
-            <formatter type="brief" usefile="false"/>
-            <formatter type="xml"/>
-        </junit>
-    </target>
-    <!-- TODO: edit the following target according to your needs -->
-    <!-- (more info: http://www.netbeans.org/kb/41/freeform-config.html#runsingle) -->
-    <target name="debug-test-selected-file-in-test">
-        <fail unless="debug.class">Must set property 'debug.class'</fail>
-        <path id="cp">
-            <pathelement path="${bin}:external/junit.jar"/>
-        </path>
-        <nbjpdastart addressproperty="jpda.address" name="jBLAS" transport="dt_socket">
-            <classpath refid="cp"/>
-        </nbjpdastart>
-        <junit errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
-            <classpath path="${classes.dir}:external/junit.jar:${test.classes.dir}"/>
-            <jvmarg value="-Xdebug"/>
-            <jvmarg value="-Xnoagent"/>
-            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
-            <test name="${debug.class}" todir="${test.results.dir}"/>
-            <formatter type="brief" usefile="false"/>
-            <formatter type="xml"/>
-        </junit>
-    </target>
-</project>
diff --git a/nbproject/project.xml b/nbproject/project.xml
deleted file mode 100644
index 7742e51..0000000
--- a/nbproject/project.xml
+++ /dev/null
@@ -1,199 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://www.netbeans.org/ns/project/1">
-    <type>org.netbeans.modules.ant.freeform</type>
-    <configuration>
-        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
-            <name>jBLAS-Array</name>
-        </general-data>
-        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
-            <!-- Do not use Project Properties customizer when editing this file manually. -->
-            <name>jBLAS-Array</name>
-            <properties/>
-            <folders>
-                <source-folder>
-                    <label>jBLAS</label>
-                    <location>.</location>
-                    <encoding>UTF-8</encoding>
-                </source-folder>
-                <source-folder>
-                    <label>src</label>
-                    <type>java</type>
-                    <location>src</location>
-                    <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    <encoding>UTF-8</encoding>
-                </source-folder>
-                <source-folder>
-                    <label>test</label>
-                    <type>java</type>
-                    <location>test</location>
-                    <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    <encoding>UTF-8</encoding>
-                </source-folder>
-                <source-folder>
-                    <label>scripts</label>
-                    <type>java</type>
-                    <location>scripts</location>
-                    <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    <encoding>UTF-8</encoding>
-                </source-folder>
-                <source-folder>
-                    <label>native</label>
-                    <type>java</type>
-                    <location>native</location>
-                    <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    <encoding>UTF-8</encoding>
-                </source-folder>
-                <source-folder>
-                    <label>include</label>
-                    <type>java</type>
-                    <location>include</location>
-                    <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    <encoding>UTF-8</encoding>
-                </source-folder>
-                <source-folder>
-                    <label>config</label>
-                    <type>java</type>
-                    <location>config</location>
-                    <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    <encoding>UTF-8</encoding>
-                </source-folder>
-            </folders>
-            <ide-actions>
-                <action name="build">
-                    <target>jar</target>
-                </action>
-                <action name="clean">
-                    <target>clean</target>
-                </action>
-                <action name="javadoc">
-                    <target>javadoc</target>
-                </action>
-                <action name="test">
-                    <target>test</target>
-                </action>
-                <action name="rebuild">
-                    <target>clean</target>
-                    <target>jar</target>
-                </action>
-                <action name="test.single">
-                    <script>nbproject/ide-file-targets.xml</script>
-                    <target>test-selected-file-in-test</target>
-                    <context>
-                        <property>run.class</property>
-                        <folder>test</folder>
-                        <pattern>\.java$</pattern>
-                        <format>java-name</format>
-                        <arity>
-                            <one-file-only/>
-                        </arity>
-                    </context>
-                </action>
-                <action name="debug.single">
-                    <script>nbproject/ide-file-targets.xml</script>
-                    <target>debug-selected-file-in-test</target>
-                    <context>
-                        <property>debug.class</property>
-                        <folder>test</folder>
-                        <pattern>\.java$</pattern>
-                        <format>java-name</format>
-                        <arity>
-                            <one-file-only/>
-                        </arity>
-                    </context>
-                </action>
-                <action name="debug.test.single">
-                    <script>nbproject/ide-file-targets.xml</script>
-                    <target>debug-test-selected-file-in-test</target>
-                    <context>
-                        <property>debug.class</property>
-                        <folder>test</folder>
-                        <pattern>\.java$</pattern>
-                        <format>java-name</format>
-                        <arity>
-                            <one-file-only/>
-                        </arity>
-                    </context>
-                </action>
-            </ide-actions>
-            <export>
-                <type>jar</type>
-                <location>jblas-1.0.2.jar</location>
-                <build-target>jar</build-target>
-            </export>
-            <view>
-                <items>
-                    <source-folder style="packages">
-                        <label>src</label>
-                        <location>src</location>
-                        <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    </source-folder>
-                    <source-folder style="packages">
-                        <label>test</label>
-                        <location>test</location>
-                        <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    </source-folder>
-                    <source-folder style="packages">
-                        <label>scripts</label>
-                        <location>scripts</location>
-                        <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    </source-folder>
-                    <source-folder style="packages">
-                        <label>native</label>
-                        <location>native</location>
-                        <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    </source-folder>
-                    <source-folder style="packages">
-                        <label>include</label>
-                        <location>include</location>
-                        <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    </source-folder>
-                    <source-folder style="packages">
-                        <label>config</label>
-                        <location>config</location>
-                        <excludes>**/doc/,**/*.rjpp,**/*.cache</excludes>
-                    </source-folder>
-                    <source-file>
-                        <location>build.xml</location>
-                    </source-file>
-                </items>
-                <context-menu>
-                    <ide-action name="build"/>
-                    <ide-action name="rebuild"/>
-                    <ide-action name="clean"/>
-                    <ide-action name="javadoc"/>
-                    <ide-action name="test"/>
-                </context-menu>
-            </view>
-            <subprojects/>
-        </general-data>
-        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
-            <compilation-unit>
-                <package-root>src</package-root>
-                <built-to>jblas-1.0.2.jar</built-to>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-            <compilation-unit>
-                <package-root>test</package-root>
-                <unit-tests/>
-                <classpath mode="compile">src:../../../../usr/share/java/junit.jar</classpath>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-            <compilation-unit>
-                <package-root>scripts</package-root>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-            <compilation-unit>
-                <package-root>native</package-root>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-            <compilation-unit>
-                <package-root>include</package-root>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-            <compilation-unit>
-                <package-root>config</package-root>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-        </java-data>
-    </configuration>
-</project>
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..62c43da
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,67 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.jblas</groupId>
+    <artifactId>jblas</artifactId>
+    <version>1.2.0</version>
+    <packaging>jar</packaging>
+
+    <name>jblas</name>
+    <url>http://maven.apache.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>org.jblas.benchmark.Main</mainClass>
+                        </manifest>
+                    </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>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/scripts/fortran/java.rb b/scripts/fortran/java.rb
index a6929ea..be7955a 100644
--- a/scripts/fortran/java.rb
+++ b/scripts/fortran/java.rb
@@ -487,8 +487,12 @@ EOS
       end
 
       def make_fortran_return_type
-        if ctype == 'jfloat'
-          code.fortran_return_type << 'jdouble'
+        if false
+          if ctype == 'jfloat'
+            code.fortran_return_type << 'jdouble'
+          else
+            code.fortran_return_type << ctype
+          end
         else
           code.fortran_return_type << ctype
         end
diff --git a/scripts/fortranwrapper.rb b/scripts/fortranwrapper.rb
index e3f4e69..99b203a 100644
--- a/scripts/fortranwrapper.rb
+++ b/scripts/fortranwrapper.rb
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 ## --- BEGIN LICENSE BLOCK ---
 # Copyright (c) 2009, Mikio L. Braun
 # All rights reserved.
@@ -134,8 +135,8 @@ if $here
   java_filename = klass + '.java'
   wrapper_filename = klass + '.c'
 else
-  java_filename = full_file_path('src', package, klass) + '.java'
-  wrapper_filename = File.join('native', klass) + '.c'
+  java_filename = full_file_path('src/main/java', package, klass) + '.java'
+  wrapper_filename = File.join('src/main/c', klass) + '.c'
 end
 
 File.open(java_filename, 'w') {|o| o.write java_class}
diff --git a/src/main/c/NativeBlas.c b/src/main/c/NativeBlas.c
new file mode 100644
index 0000000..71b814e
--- /dev/null
+++ b/src/main/c/NativeBlas.c
@@ -0,0 +1,4340 @@
+/// --- BEGIN LICENSE BLOCK ---
+// Copyright (c) 2009, Mikio L. Braun
+// 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.
+/// --- END LICENSE BLOCK ---
+
+#include "org_jblas_NativeBlas.h"
+
+#define CORE_PACKAGE "org/jblas/"
+
+/*
+ * For convenience, we define some typedefs here which have the
+ * same name as certain Java types, but their implementation differs (of course)
+ */
+typedef char *String;
+
+typedef char ByteBuffer;
+typedef short ShortBuffer;
+typedef int IntBuffer;
+typedef long LongBuffer;
+typedef float FloatBuffer;
+typedef double DoubleBuffer;
+
+/* a function to create new objects */
+static jobject createObject(JNIEnv *env, const char *className, const char *signature, ...)
+{
+  va_list args;
+  jclass klass = (*env)->FindClass(env, className);
+  jmethodID init = (*env)->GetMethodID(env, klass, "<init>", signature);
+  jobject newObject;
+
+  va_start(args, signature);
+  newObject = (*env)->NewObjectV(env, klass, init, args);
+  va_end(args);
+}
+
+
+#include <complex.h>
+typedef float complex ComplexFloat;
+typedef double complex ComplexDouble;
+
+static jobject createComplexFloat(JNIEnv *env, ComplexFloat fc) {
+  return createObject(env, CORE_PACKAGE "ComplexFloat", "(FF)V", crealf(fc), cimagf(fc));
+}
+
+static jobject createComplexDouble(JNIEnv *env, ComplexDouble dc)
+{
+  return createObject(env, CORE_PACKAGE "ComplexDouble", "(DD)V", creal(dc), cimag(dc));
+}
+
+static ComplexFloat getComplexFloat(JNIEnv *env, jobject fc)
+{
+  jclass klass = (*env)->FindClass(env, CORE_PACKAGE "ComplexFloat");
+  jfieldID reField = (*env)->GetFieldID(env, klass, "r", "F");
+  jfieldID imField = (*env)->GetFieldID(env, klass, "i", "F");
+
+  return (*env)->GetFloatField(env, fc, reField) + I*(*env)->GetFloatField(env, fc, imField);
+}
+
+static ComplexDouble getComplexDouble(JNIEnv *env, jobject dc)
+{
+  jclass klass = (*env)->FindClass(env, CORE_PACKAGE "ComplexDouble");
+  jfieldID reField = (*env)->GetFieldID(env, klass, "r", "D");
+  jfieldID imField = (*env)->GetFieldID(env, klass, "i", "D");
+
+  return (*env)->GetDoubleField(env, dc, reField) + I*(*env)->GetDoubleField(env, dc, imField);
+}
+
+
+static void throwIllegalArgumentException(JNIEnv *env, const char *message)
+{
+  jclass klass = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+
+  (*env)->ThrowNew(env, klass, message);
+}
+
+/**********************************************************************/
+/*                 XERBLA function arguments                          */
+/**********************************************************************/
+
+static char *routine_names[] = {
+ "CAXPY",  "CCOPY",  "CDOTC",  "CDOTU",  "CGEEV",  "CGEMM",  "CGEMV",  "CGERC",  "CGERU",  "CGESVD",  "CSCAL",  "CSSCAL",  "CSWAP",  "DASUM",  "DAXPY",  "DCOPY",  "DDOT",  "DGEEV",  "DGEMM",  "DGEMV",  "DGER",  "DGESV",  "DGESVD",  "DGETRF",  "DNRM2",  "DPOSV",  "DPOTRF",  "DSCAL",  "DSWAP",  "DSYEV",  "DSYEVD",  "DSYEVR",  "DSYEVX",  "DSYGVD",  "DSYSV",  "DZASUM",  "DZNRM2",  "ICAMAX",  "IDAMAX",  "ISAMAX",  "IZAMAX",  "SASUM",  "SAXPY",  "SCASUM",  "SCNRM2",  "SCOPY",  "SDOT",  "SGEEV" [...]
+};
+
+static char *routine_arguments[][21] = {
+   { "N", "CA", "CX", "INCX", "CY", "INCY" }, 
+   { "N", "CX", "INCX", "CY", "INCY" }, 
+   { "N", "CX", "INCX", "CY", "INCY" }, 
+   { "N", "CX", "INCX", "CY", "INCY" }, 
+   { "JOBVL", "JOBVR", "N", "A", "LDA", "W", "VL", "LDVL", "VR", "LDVR", "WORK", "LWORK", "RWORK", "INFO" }, 
+   { "TRANSA", "TRANSB", "M", "N", "K", "ALPHA", "A", "LDA", "B", "LDB", "BETA", "C", "LDC" }, 
+   { "TRANS", "M", "N", "ALPHA", "A", "LDA", "X", "INCX", "BETA", "Y", "INCY" }, 
+   { "M", "N", "ALPHA", "X", "INCX", "Y", "INCY", "A", "LDA" }, 
+   { "M", "N", "ALPHA", "X", "INCX", "Y", "INCY", "A", "LDA" }, 
+   { "JOBU", "JOBVT", "M", "N", "A", "LDA", "S", "U", "LDU", "VT", "LDVT", "WORK", "LWORK", "RWORK", "INFO" }, 
+   { "N", "CA", "CX", "INCX" }, 
+   { "N", "SA", "CX", "INCX" }, 
+   { "N", "CX", "INCX", "CY", "INCY" }, 
+   { "N", "DX", "INCX" }, 
+   { "N", "DA", "DX", "INCX", "DY", "INCY" }, 
+   { "N", "DX", "INCX", "DY", "INCY" }, 
+   { "N", "DX", "INCX", "DY", "INCY" }, 
+   { "JOBVL", "JOBVR", "N", "A", "LDA", "WR", "WI", "VL", "LDVL", "VR", "LDVR", "WORK", "LWORK", "INFO" }, 
+   { "TRANSA", "TRANSB", "M", "N", "K", "ALPHA", "A", "LDA", "B", "LDB", "BETA", "C", "LDC" }, 
+   { "TRANS", "M", "N", "ALPHA", "A", "LDA", "X", "INCX", "BETA", "Y", "INCY" }, 
+   { "M", "N", "ALPHA", "X", "INCX", "Y", "INCY", "A", "LDA" }, 
+   { "N", "NRHS", "A", "LDA", "IPIV", "B", "LDB", "INFO" }, 
+   { "JOBU", "JOBVT", "M", "N", "A", "LDA", "S", "U", "LDU", "VT", "LDVT", "WORK", "LWORK", "INFO" }, 
+   { "M", "N", "A", "LDA", "IPIV", "INFO" }, 
+   { "N", "X", "INCX" }, 
+   { "UPLO", "N", "NRHS", "A", "LDA", "B", "LDB", "INFO" }, 
+   { "UPLO", "N", "A", "LDA", "INFO" }, 
+   { "N", "DA", "DX", "INCX" }, 
+   { "N", "DX", "INCX", "DY", "INCY" }, 
+   { "JOBZ", "UPLO", "N", "A", "LDA", "W", "WORK", "LWORK", "INFO" }, 
+   { "JOBZ", "UPLO", "N", "A", "LDA", "W", "WORK", "LWORK", "IWORK", "LIWORK", "INFO" }, 
+   { "JOBZ", "RANGE", "UPLO", "N", "A", "LDA", "VL", "VU", "IL", "IU", "ABSTOL", "M", "W", "Z", "LDZ", "ISUPPZ", "WORK", "LWORK", "IWORK", "LIWORK", "INFO" }, 
+   { "JOBZ", "RANGE", "UPLO", "N", "A", "LDA", "VL", "VU", "IL", "IU", "ABSTOL", "M", "W", "Z", "LDZ", "WORK", "LWORK", "IWORK", "IFAIL", "INFO" }, 
+   { "ITYPE", "JOBZ", "UPLO", "N", "A", "LDA", "B", "LDB", "W", "WORK", "LWORK", "IWORK", "LIWORK", "INFO" }, 
+   { "UPLO", "N", "NRHS", "A", "LDA", "IPIV", "B", "LDB", "WORK", "LWORK", "INFO" }, 
+   { "N", "ZX", "INCX" }, 
+   { "N", "X", "INCX" }, 
+   { "N", "CX", "INCX" }, 
+   { "N", "DX", "INCX" }, 
+   { "N", "SX", "INCX" }, 
+   { "N", "ZX", "INCX" }, 
+   { "N", "SX", "INCX" }, 
+   { "N", "SA", "SX", "INCX", "SY", "INCY" }, 
+   { "N", "CX", "INCX" }, 
+   { "N", "X", "INCX" }, 
+   { "N", "SX", "INCX", "SY", "INCY" }, 
+   { "N", "SX", "INCX", "SY", "INCY" }, 
+   { "JOBVL", "JOBVR", "N", "A", "LDA", "WR", "WI", "VL", "LDVL", "VR", "LDVR", "WORK", "LWORK", "INFO" }, 
+   { "TRANSA", "TRANSB", "M", "N", "K", "ALPHA", "A", "LDA", "B", "LDB", "BETA", "C", "LDC" }, 
+   { "TRANS", "M", "N", "ALPHA", "A", "LDA", "X", "INCX", "BETA", "Y", "INCY" }, 
+   { "M", "N", "ALPHA", "X", "INCX", "Y", "INCY", "A", "LDA" }, 
+   { "N", "NRHS", "A", "LDA", "IPIV", "B", "LDB", "INFO" }, 
+   { "JOBU", "JOBVT", "M", "N", "A", "LDA", "S", "U", "LDU", "VT", "LDVT", "WORK", "LWORK", "INFO" }, 
+   { "M", "N", "A", "LDA", "IPIV", "INFO" }, 
+   { "N", "X", "INCX" }, 
+   { "UPLO", "N", "NRHS", "A", "LDA", "B", "LDB", "INFO" }, 
+   { "UPLO", "N", "A", "LDA", "INFO" }, 
+   { "N", "SA", "SX", "INCX" }, 
+   { "N", "SX", "INCX", "SY", "INCY" }, 
+   { "JOBZ", "UPLO", "N", "A", "LDA", "W", "WORK", "LWORK", "INFO" }, 
+   { "JOBZ", "UPLO", "N", "A", "LDA", "W", "WORK", "LWORK", "IWORK", "LIWORK", "INFO" }, 
+   { "JOBZ", "RANGE", "UPLO", "N", "A", "LDA", "VL", "VU", "IL", "IU", "ABSTOL", "M", "W", "Z", "LDZ", "ISUPPZ", "WORK", "LWORK", "IWORK", "LIWORK", "INFO" }, 
+   { "JOBZ", "RANGE", "UPLO", "N", "A", "LDA", "VL", "VU", "IL", "IU", "ABSTOL", "M", "W", "Z", "LDZ", "WORK", "LWORK", "IWORK", "IFAIL", "INFO" }, 
+   { "ITYPE", "JOBZ", "UPLO", "N", "A", "LDA", "B", "LDB", "W", "WORK", "LWORK", "IWORK", "LIWORK", "INFO" }, 
+   { "UPLO", "N", "NRHS", "A", "LDA", "IPIV", "B", "LDB", "WORK", "LWORK", "INFO" }, 
+   { "N", "ZA", "ZX", "INCX", "ZY", "INCY" }, 
+   { "N", "ZX", "INCX", "ZY", "INCY" }, 
+   { "N", "ZX", "INCX", "ZY", "INCY" }, 
+   { "N", "ZX", "INCX", "ZY", "INCY" }, 
+   { "N", "DA", "ZX", "INCX" }, 
+   { "JOBVL", "JOBVR", "N", "A", "LDA", "W", "VL", "LDVL", "VR", "LDVR", "WORK", "LWORK", "RWORK", "INFO" }, 
+   { "TRANSA", "TRANSB", "M", "N", "K", "ALPHA", "A", "LDA", "B", "LDB", "BETA", "C", "LDC" }, 
+   { "TRANS", "M", "N", "ALPHA", "A", "LDA", "X", "INCX", "BETA", "Y", "INCY" }, 
+   { "M", "N", "ALPHA", "X", "INCX", "Y", "INCY", "A", "LDA" }, 
+   { "M", "N", "ALPHA", "X", "INCX", "Y", "INCY", "A", "LDA" }, 
+   { "JOBU", "JOBVT", "M", "N", "A", "LDA", "S", "U", "LDU", "VT", "LDVT", "WORK", "LWORK", "RWORK", "INFO" }, 
+   { "N", "ZA", "ZX", "INCX" }, 
+   { "N", "ZX", "INCX", "ZY", "INCY" }, 
+};
+
+/**********************************************************************/
+/*                 Our implementation of XERBLA                       */
+/**********************************************************************/
+static JNIEnv *savedEnv = 0;
+
+
+void xerbla_(char *fct, int *info)
+{
+	static char name[7];
+	static char buffer[256];
+	int i;
+	char **p;
+	char **arguments = 0;
+	
+	for (i = 0; i < 6; i++) {
+		if (fct[i] == ' ')
+			break;	
+		name[i] = fct[i];
+	}
+	name[i] = '\0';
+	
+	//fprintf(stderr, "Searching for function \"%s\"\n", name);
+	
+	for (p = routine_names, i = 0; *p; p++, i++)
+		if (!strcmp(*p, name))
+			arguments = routine_arguments[i];
+			
+	if (!arguments) {
+		sprintf(buffer, "XERBLA: Error on argument %d for *unknown function* %s (how odd!)\n", *info, name);
+	}
+	else {
+		sprintf(buffer, "XERBLA: Error on argument %d (%s) in %s", *info, arguments[*info-1], name);
+	}
+	throwIllegalArgumentException(savedEnv, buffer);
+}
+
+/**********************************************************************/
+/*                 generated functions below                          */
+/**********************************************************************/
+
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_ccopy(JNIEnv *env, jclass this, jint n, jfloatArray cx, jint cxIdx, jint incx, jfloatArray cy, jint cyIdx, jint incy)
+{
+  extern void ccopy_(jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  jfloat *cxPtrBase = 0, *cxPtr = 0;
+  if (cx) {
+    cxPtrBase = (*env)->GetFloatArrayElements(env, cx, NULL);
+    cxPtr = cxPtrBase + 2*cxIdx;
+  }
+  jfloat *cyPtrBase = 0, *cyPtr = 0;
+  if (cy) {
+    if((*env)->IsSameObject(env, cy, cx) == JNI_TRUE)
+      cyPtrBase = cxPtrBase;
+    else
+      cyPtrBase = (*env)->GetFloatArrayElements(env, cy, NULL);
+    cyPtr = cyPtrBase + 2*cyIdx;
+  }
+
+  savedEnv = env;
+  ccopy_(&n, cxPtr, &incx, cyPtr, &incy);
+  if(cyPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cy, cyPtrBase, 0);
+    if (cyPtrBase == cxPtrBase)
+      cxPtrBase = 0;
+    cyPtrBase = 0;
+  }
+  if(cxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cx, cxPtrBase, 0);
+    cxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dcopy(JNIEnv *env, jclass this, jint n, jdoubleArray dx, jint dxIdx, jint incx, jdoubleArray dy, jint dyIdx, jint incy)
+{
+  extern void dcopy_(jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  jdouble *dxPtrBase = 0, *dxPtr = 0;
+  if (dx) {
+    dxPtrBase = (*env)->GetDoubleArrayElements(env, dx, NULL);
+    dxPtr = dxPtrBase + dxIdx;
+  }
+  jdouble *dyPtrBase = 0, *dyPtr = 0;
+  if (dy) {
+    if((*env)->IsSameObject(env, dy, dx) == JNI_TRUE)
+      dyPtrBase = dxPtrBase;
+    else
+      dyPtrBase = (*env)->GetDoubleArrayElements(env, dy, NULL);
+    dyPtr = dyPtrBase + dyIdx;
+  }
+
+  savedEnv = env;
+  dcopy_(&n, dxPtr, &incx, dyPtr, &incy);
+  if(dyPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dy, dyPtrBase, 0);
+    if (dyPtrBase == dxPtrBase)
+      dxPtrBase = 0;
+    dyPtrBase = 0;
+  }
+  if(dxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dx, dxPtrBase, 0);
+    dxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_scopy(JNIEnv *env, jclass this, jint n, jfloatArray sx, jint sxIdx, jint incx, jfloatArray sy, jint syIdx, jint incy)
+{
+  extern void scopy_(jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  jfloat *sxPtrBase = 0, *sxPtr = 0;
+  if (sx) {
+    sxPtrBase = (*env)->GetFloatArrayElements(env, sx, NULL);
+    sxPtr = sxPtrBase + sxIdx;
+  }
+  jfloat *syPtrBase = 0, *syPtr = 0;
+  if (sy) {
+    if((*env)->IsSameObject(env, sy, sx) == JNI_TRUE)
+      syPtrBase = sxPtrBase;
+    else
+      syPtrBase = (*env)->GetFloatArrayElements(env, sy, NULL);
+    syPtr = syPtrBase + syIdx;
+  }
+
+  savedEnv = env;
+  scopy_(&n, sxPtr, &incx, syPtr, &incy);
+  if(syPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sy, syPtrBase, 0);
+    if (syPtrBase == sxPtrBase)
+      sxPtrBase = 0;
+    syPtrBase = 0;
+  }
+  if(sxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sx, sxPtrBase, 0);
+    sxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zcopy(JNIEnv *env, jclass this, jint n, jdoubleArray zx, jint zxIdx, jint incx, jdoubleArray zy, jint zyIdx, jint incy)
+{
+  extern void zcopy_(jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  jdouble *zxPtrBase = 0, *zxPtr = 0;
+  if (zx) {
+    zxPtrBase = (*env)->GetDoubleArrayElements(env, zx, NULL);
+    zxPtr = zxPtrBase + 2*zxIdx;
+  }
+  jdouble *zyPtrBase = 0, *zyPtr = 0;
+  if (zy) {
+    if((*env)->IsSameObject(env, zy, zx) == JNI_TRUE)
+      zyPtrBase = zxPtrBase;
+    else
+      zyPtrBase = (*env)->GetDoubleArrayElements(env, zy, NULL);
+    zyPtr = zyPtrBase + 2*zyIdx;
+  }
+
+  savedEnv = env;
+  zcopy_(&n, zxPtr, &incx, zyPtr, &incy);
+  if(zyPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zy, zyPtrBase, 0);
+    if (zyPtrBase == zxPtrBase)
+      zxPtrBase = 0;
+    zyPtrBase = 0;
+  }
+  if(zxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zx, zxPtrBase, 0);
+    zxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cswap(JNIEnv *env, jclass this, jint n, jfloatArray cx, jint cxIdx, jint incx, jfloatArray cy, jint cyIdx, jint incy)
+{
+  extern void cswap_(jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  jfloat *cxPtrBase = 0, *cxPtr = 0;
+  if (cx) {
+    cxPtrBase = (*env)->GetFloatArrayElements(env, cx, NULL);
+    cxPtr = cxPtrBase + 2*cxIdx;
+  }
+  jfloat *cyPtrBase = 0, *cyPtr = 0;
+  if (cy) {
+    if((*env)->IsSameObject(env, cy, cx) == JNI_TRUE)
+      cyPtrBase = cxPtrBase;
+    else
+      cyPtrBase = (*env)->GetFloatArrayElements(env, cy, NULL);
+    cyPtr = cyPtrBase + 2*cyIdx;
+  }
+
+  savedEnv = env;
+  cswap_(&n, cxPtr, &incx, cyPtr, &incy);
+  if(cyPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cy, cyPtrBase, 0);
+    if (cyPtrBase == cxPtrBase)
+      cxPtrBase = 0;
+    cyPtrBase = 0;
+  }
+  if(cxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cx, cxPtrBase, 0);
+    cxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dswap(JNIEnv *env, jclass this, jint n, jdoubleArray dx, jint dxIdx, jint incx, jdoubleArray dy, jint dyIdx, jint incy)
+{
+  extern void dswap_(jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  jdouble *dxPtrBase = 0, *dxPtr = 0;
+  if (dx) {
+    dxPtrBase = (*env)->GetDoubleArrayElements(env, dx, NULL);
+    dxPtr = dxPtrBase + dxIdx;
+  }
+  jdouble *dyPtrBase = 0, *dyPtr = 0;
+  if (dy) {
+    if((*env)->IsSameObject(env, dy, dx) == JNI_TRUE)
+      dyPtrBase = dxPtrBase;
+    else
+      dyPtrBase = (*env)->GetDoubleArrayElements(env, dy, NULL);
+    dyPtr = dyPtrBase + dyIdx;
+  }
+
+  savedEnv = env;
+  dswap_(&n, dxPtr, &incx, dyPtr, &incy);
+  if(dyPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dy, dyPtrBase, 0);
+    if (dyPtrBase == dxPtrBase)
+      dxPtrBase = 0;
+    dyPtrBase = 0;
+  }
+  if(dxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dx, dxPtrBase, 0);
+    dxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sswap(JNIEnv *env, jclass this, jint n, jfloatArray sx, jint sxIdx, jint incx, jfloatArray sy, jint syIdx, jint incy)
+{
+  extern void sswap_(jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  jfloat *sxPtrBase = 0, *sxPtr = 0;
+  if (sx) {
+    sxPtrBase = (*env)->GetFloatArrayElements(env, sx, NULL);
+    sxPtr = sxPtrBase + sxIdx;
+  }
+  jfloat *syPtrBase = 0, *syPtr = 0;
+  if (sy) {
+    if((*env)->IsSameObject(env, sy, sx) == JNI_TRUE)
+      syPtrBase = sxPtrBase;
+    else
+      syPtrBase = (*env)->GetFloatArrayElements(env, sy, NULL);
+    syPtr = syPtrBase + syIdx;
+  }
+
+  savedEnv = env;
+  sswap_(&n, sxPtr, &incx, syPtr, &incy);
+  if(syPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sy, syPtrBase, 0);
+    if (syPtrBase == sxPtrBase)
+      sxPtrBase = 0;
+    syPtrBase = 0;
+  }
+  if(sxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sx, sxPtrBase, 0);
+    sxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zswap(JNIEnv *env, jclass this, jint n, jdoubleArray zx, jint zxIdx, jint incx, jdoubleArray zy, jint zyIdx, jint incy)
+{
+  extern void zswap_(jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  jdouble *zxPtrBase = 0, *zxPtr = 0;
+  if (zx) {
+    zxPtrBase = (*env)->GetDoubleArrayElements(env, zx, NULL);
+    zxPtr = zxPtrBase + 2*zxIdx;
+  }
+  jdouble *zyPtrBase = 0, *zyPtr = 0;
+  if (zy) {
+    if((*env)->IsSameObject(env, zy, zx) == JNI_TRUE)
+      zyPtrBase = zxPtrBase;
+    else
+      zyPtrBase = (*env)->GetDoubleArrayElements(env, zy, NULL);
+    zyPtr = zyPtrBase + 2*zyIdx;
+  }
+
+  savedEnv = env;
+  zswap_(&n, zxPtr, &incx, zyPtr, &incy);
+  if(zyPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zy, zyPtrBase, 0);
+    if (zyPtrBase == zxPtrBase)
+      zxPtrBase = 0;
+    zyPtrBase = 0;
+  }
+  if(zxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zx, zxPtrBase, 0);
+    zxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_caxpy(JNIEnv *env, jclass this, jint n, jobject ca, jfloatArray cx, jint cxIdx, jint incx, jfloatArray cy, jint cyIdx, jint incy)
+{
+  extern void caxpy_(jint *, float complex *, jfloat *, jint *, jfloat *, jint *);
+  
+  float complex caCplx;
+  caCplx = getComplexFloat(env, ca);
+  jfloat *cxPtrBase = 0, *cxPtr = 0;
+  if (cx) {
+    cxPtrBase = (*env)->GetFloatArrayElements(env, cx, NULL);
+    cxPtr = cxPtrBase + 2*cxIdx;
+  }
+  jfloat *cyPtrBase = 0, *cyPtr = 0;
+  if (cy) {
+    if((*env)->IsSameObject(env, cy, cx) == JNI_TRUE)
+      cyPtrBase = cxPtrBase;
+    else
+      cyPtrBase = (*env)->GetFloatArrayElements(env, cy, NULL);
+    cyPtr = cyPtrBase + 2*cyIdx;
+  }
+
+  savedEnv = env;
+  caxpy_(&n, &caCplx, cxPtr, &incx, cyPtr, &incy);
+  if(cyPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cy, cyPtrBase, 0);
+    if (cyPtrBase == cxPtrBase)
+      cxPtrBase = 0;
+    cyPtrBase = 0;
+  }
+  if(cxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cx, cxPtrBase, 0);
+    cxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_daxpy(JNIEnv *env, jclass this, jint n, jdouble da, jdoubleArray dx, jint dxIdx, jint incx, jdoubleArray dy, jint dyIdx, jint incy)
+{
+  extern void daxpy_(jint *, jdouble *, jdouble *, jint *, jdouble *, jint *);
+  
+  jdouble *dxPtrBase = 0, *dxPtr = 0;
+  if (dx) {
+    dxPtrBase = (*env)->GetDoubleArrayElements(env, dx, NULL);
+    dxPtr = dxPtrBase + dxIdx;
+  }
+  jdouble *dyPtrBase = 0, *dyPtr = 0;
+  if (dy) {
+    if((*env)->IsSameObject(env, dy, dx) == JNI_TRUE)
+      dyPtrBase = dxPtrBase;
+    else
+      dyPtrBase = (*env)->GetDoubleArrayElements(env, dy, NULL);
+    dyPtr = dyPtrBase + dyIdx;
+  }
+
+  savedEnv = env;
+  daxpy_(&n, &da, dxPtr, &incx, dyPtr, &incy);
+  if(dyPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dy, dyPtrBase, 0);
+    if (dyPtrBase == dxPtrBase)
+      dxPtrBase = 0;
+    dyPtrBase = 0;
+  }
+  if(dxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dx, dxPtrBase, 0);
+    dxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_saxpy(JNIEnv *env, jclass this, jint n, jfloat sa, jfloatArray sx, jint sxIdx, jint incx, jfloatArray sy, jint syIdx, jint incy)
+{
+  extern void saxpy_(jint *, jfloat *, jfloat *, jint *, jfloat *, jint *);
+  
+  jfloat *sxPtrBase = 0, *sxPtr = 0;
+  if (sx) {
+    sxPtrBase = (*env)->GetFloatArrayElements(env, sx, NULL);
+    sxPtr = sxPtrBase + sxIdx;
+  }
+  jfloat *syPtrBase = 0, *syPtr = 0;
+  if (sy) {
+    if((*env)->IsSameObject(env, sy, sx) == JNI_TRUE)
+      syPtrBase = sxPtrBase;
+    else
+      syPtrBase = (*env)->GetFloatArrayElements(env, sy, NULL);
+    syPtr = syPtrBase + syIdx;
+  }
+
+  savedEnv = env;
+  saxpy_(&n, &sa, sxPtr, &incx, syPtr, &incy);
+  if(syPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sy, syPtrBase, 0);
+    if (syPtrBase == sxPtrBase)
+      sxPtrBase = 0;
+    syPtrBase = 0;
+  }
+  if(sxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sx, sxPtrBase, 0);
+    sxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zaxpy(JNIEnv *env, jclass this, jint n, jobject za, jdoubleArray zx, jint zxIdx, jint incx, jdoubleArray zy, jint zyIdx, jint incy)
+{
+  extern void zaxpy_(jint *, double complex *, jdouble *, jint *, jdouble *, jint *);
+  
+  double complex zaCplx;
+  zaCplx = getComplexDouble(env, za);
+  jdouble *zxPtrBase = 0, *zxPtr = 0;
+  if (zx) {
+    zxPtrBase = (*env)->GetDoubleArrayElements(env, zx, NULL);
+    zxPtr = zxPtrBase + 2*zxIdx;
+  }
+  jdouble *zyPtrBase = 0, *zyPtr = 0;
+  if (zy) {
+    if((*env)->IsSameObject(env, zy, zx) == JNI_TRUE)
+      zyPtrBase = zxPtrBase;
+    else
+      zyPtrBase = (*env)->GetDoubleArrayElements(env, zy, NULL);
+    zyPtr = zyPtrBase + 2*zyIdx;
+  }
+
+  savedEnv = env;
+  zaxpy_(&n, &zaCplx, zxPtr, &incx, zyPtr, &incy);
+  if(zyPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zy, zyPtrBase, 0);
+    if (zyPtrBase == zxPtrBase)
+      zxPtrBase = 0;
+    zyPtrBase = 0;
+  }
+  if(zxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zx, zxPtrBase, 0);
+    zxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cscal(JNIEnv *env, jclass this, jint n, jobject ca, jfloatArray cx, jint cxIdx, jint incx)
+{
+  extern void cscal_(jint *, float complex *, jfloat *, jint *);
+  
+  float complex caCplx;
+  caCplx = getComplexFloat(env, ca);
+  jfloat *cxPtrBase = 0, *cxPtr = 0;
+  if (cx) {
+    cxPtrBase = (*env)->GetFloatArrayElements(env, cx, NULL);
+    cxPtr = cxPtrBase + 2*cxIdx;
+  }
+
+  savedEnv = env;
+  cscal_(&n, &caCplx, cxPtr, &incx);
+  if(cxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cx, cxPtrBase, 0);
+    cxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dscal(JNIEnv *env, jclass this, jint n, jdouble da, jdoubleArray dx, jint dxIdx, jint incx)
+{
+  extern void dscal_(jint *, jdouble *, jdouble *, jint *);
+  
+  jdouble *dxPtrBase = 0, *dxPtr = 0;
+  if (dx) {
+    dxPtrBase = (*env)->GetDoubleArrayElements(env, dx, NULL);
+    dxPtr = dxPtrBase + dxIdx;
+  }
+
+  savedEnv = env;
+  dscal_(&n, &da, dxPtr, &incx);
+  if(dxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dx, dxPtrBase, 0);
+    dxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sscal(JNIEnv *env, jclass this, jint n, jfloat sa, jfloatArray sx, jint sxIdx, jint incx)
+{
+  extern void sscal_(jint *, jfloat *, jfloat *, jint *);
+  
+  jfloat *sxPtrBase = 0, *sxPtr = 0;
+  if (sx) {
+    sxPtrBase = (*env)->GetFloatArrayElements(env, sx, NULL);
+    sxPtr = sxPtrBase + sxIdx;
+  }
+
+  savedEnv = env;
+  sscal_(&n, &sa, sxPtr, &incx);
+  if(sxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sx, sxPtrBase, 0);
+    sxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zscal(JNIEnv *env, jclass this, jint n, jobject za, jdoubleArray zx, jint zxIdx, jint incx)
+{
+  extern void zscal_(jint *, double complex *, jdouble *, jint *);
+  
+  double complex zaCplx;
+  zaCplx = getComplexDouble(env, za);
+  jdouble *zxPtrBase = 0, *zxPtr = 0;
+  if (zx) {
+    zxPtrBase = (*env)->GetDoubleArrayElements(env, zx, NULL);
+    zxPtr = zxPtrBase + 2*zxIdx;
+  }
+
+  savedEnv = env;
+  zscal_(&n, &zaCplx, zxPtr, &incx);
+  if(zxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zx, zxPtrBase, 0);
+    zxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_csscal(JNIEnv *env, jclass this, jint n, jfloat sa, jfloatArray cx, jint cxIdx, jint incx)
+{
+  extern void csscal_(jint *, jfloat *, jfloat *, jint *);
+  
+  jfloat *cxPtrBase = 0, *cxPtr = 0;
+  if (cx) {
+    cxPtrBase = (*env)->GetFloatArrayElements(env, cx, NULL);
+    cxPtr = cxPtrBase + 2*cxIdx;
+  }
+
+  savedEnv = env;
+  csscal_(&n, &sa, cxPtr, &incx);
+  if(cxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cx, cxPtrBase, 0);
+    cxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zdscal(JNIEnv *env, jclass this, jint n, jdouble da, jdoubleArray zx, jint zxIdx, jint incx)
+{
+  extern void zdscal_(jint *, jdouble *, jdouble *, jint *);
+  
+  jdouble *zxPtrBase = 0, *zxPtr = 0;
+  if (zx) {
+    zxPtrBase = (*env)->GetDoubleArrayElements(env, zx, NULL);
+    zxPtr = zxPtrBase + 2*zxIdx;
+  }
+
+  savedEnv = env;
+  zdscal_(&n, &da, zxPtr, &incx);
+  if(zxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zx, zxPtrBase, 0);
+    zxPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT jobject JNICALL Java_org_jblas_NativeBlas_cdotc(JNIEnv *env, jclass this, jint n, jfloatArray cx, jint cxIdx, jint incx, jfloatArray cy, jint cyIdx, jint incy)
+{
+  extern float complex cdotc_(jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  jfloat *cxPtrBase = 0, *cxPtr = 0;
+  if (cx) {
+    cxPtrBase = (*env)->GetFloatArrayElements(env, cx, NULL);
+    cxPtr = cxPtrBase + 2*cxIdx;
+  }
+  jfloat *cyPtrBase = 0, *cyPtr = 0;
+  if (cy) {
+    if((*env)->IsSameObject(env, cy, cx) == JNI_TRUE)
+      cyPtrBase = cxPtrBase;
+    else
+      cyPtrBase = (*env)->GetFloatArrayElements(env, cy, NULL);
+    cyPtr = cyPtrBase + 2*cyIdx;
+  }
+
+  savedEnv = env;
+  float complex retval = cdotc_(&n, cxPtr, &incx, cyPtr, &incy);
+  if(cyPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cy, cyPtrBase, 0);
+    if (cyPtrBase == cxPtrBase)
+      cxPtrBase = 0;
+    cyPtrBase = 0;
+  }
+  if(cxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cx, cxPtrBase, 0);
+    cxPtrBase = 0;
+  }
+
+  return createComplexFloat(env, retval);
+}
+
+JNIEXPORT jobject JNICALL Java_org_jblas_NativeBlas_cdotu(JNIEnv *env, jclass this, jint n, jfloatArray cx, jint cxIdx, jint incx, jfloatArray cy, jint cyIdx, jint incy)
+{
+  extern float complex cdotu_(jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  jfloat *cxPtrBase = 0, *cxPtr = 0;
+  if (cx) {
+    cxPtrBase = (*env)->GetFloatArrayElements(env, cx, NULL);
+    cxPtr = cxPtrBase + 2*cxIdx;
+  }
+  jfloat *cyPtrBase = 0, *cyPtr = 0;
+  if (cy) {
+    if((*env)->IsSameObject(env, cy, cx) == JNI_TRUE)
+      cyPtrBase = cxPtrBase;
+    else
+      cyPtrBase = (*env)->GetFloatArrayElements(env, cy, NULL);
+    cyPtr = cyPtrBase + 2*cyIdx;
+  }
+
+  savedEnv = env;
+  float complex retval = cdotu_(&n, cxPtr, &incx, cyPtr, &incy);
+  if(cyPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cy, cyPtrBase, 0);
+    if (cyPtrBase == cxPtrBase)
+      cxPtrBase = 0;
+    cyPtrBase = 0;
+  }
+  if(cxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cx, cxPtrBase, 0);
+    cxPtrBase = 0;
+  }
+
+  return createComplexFloat(env, retval);
+}
+
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_ddot(JNIEnv *env, jclass this, jint n, jdoubleArray dx, jint dxIdx, jint incx, jdoubleArray dy, jint dyIdx, jint incy)
+{
+  extern jdouble ddot_(jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  jdouble *dxPtrBase = 0, *dxPtr = 0;
+  if (dx) {
+    dxPtrBase = (*env)->GetDoubleArrayElements(env, dx, NULL);
+    dxPtr = dxPtrBase + dxIdx;
+  }
+  jdouble *dyPtrBase = 0, *dyPtr = 0;
+  if (dy) {
+    if((*env)->IsSameObject(env, dy, dx) == JNI_TRUE)
+      dyPtrBase = dxPtrBase;
+    else
+      dyPtrBase = (*env)->GetDoubleArrayElements(env, dy, NULL);
+    dyPtr = dyPtrBase + dyIdx;
+  }
+
+  savedEnv = env;
+  jdouble retval = ddot_(&n, dxPtr, &incx, dyPtr, &incy);
+  if(dyPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dy, dyPtrBase, 0);
+    if (dyPtrBase == dxPtrBase)
+      dxPtrBase = 0;
+    dyPtrBase = 0;
+  }
+  if(dxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dx, dxPtrBase, 0);
+    dxPtrBase = 0;
+  }
+
+  return retval;
+}
+
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_sdot(JNIEnv *env, jclass this, jint n, jfloatArray sx, jint sxIdx, jint incx, jfloatArray sy, jint syIdx, jint incy)
+{
+  extern jfloat sdot_(jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  jfloat *sxPtrBase = 0, *sxPtr = 0;
+  if (sx) {
+    sxPtrBase = (*env)->GetFloatArrayElements(env, sx, NULL);
+    sxPtr = sxPtrBase + sxIdx;
+  }
+  jfloat *syPtrBase = 0, *syPtr = 0;
+  if (sy) {
+    if((*env)->IsSameObject(env, sy, sx) == JNI_TRUE)
+      syPtrBase = sxPtrBase;
+    else
+      syPtrBase = (*env)->GetFloatArrayElements(env, sy, NULL);
+    syPtr = syPtrBase + syIdx;
+  }
+
+  savedEnv = env;
+  jfloat retval = sdot_(&n, sxPtr, &incx, syPtr, &incy);
+  if(syPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sy, syPtrBase, 0);
+    if (syPtrBase == sxPtrBase)
+      sxPtrBase = 0;
+    syPtrBase = 0;
+  }
+  if(sxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sx, sxPtrBase, 0);
+    sxPtrBase = 0;
+  }
+
+  return (jdouble) retval;
+}
+
+JNIEXPORT jobject JNICALL Java_org_jblas_NativeBlas_zdotc(JNIEnv *env, jclass this, jint n, jdoubleArray zx, jint zxIdx, jint incx, jdoubleArray zy, jint zyIdx, jint incy)
+{
+  extern double complex zdotc_(jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  jdouble *zxPtrBase = 0, *zxPtr = 0;
+  if (zx) {
+    zxPtrBase = (*env)->GetDoubleArrayElements(env, zx, NULL);
+    zxPtr = zxPtrBase + 2*zxIdx;
+  }
+  jdouble *zyPtrBase = 0, *zyPtr = 0;
+  if (zy) {
+    if((*env)->IsSameObject(env, zy, zx) == JNI_TRUE)
+      zyPtrBase = zxPtrBase;
+    else
+      zyPtrBase = (*env)->GetDoubleArrayElements(env, zy, NULL);
+    zyPtr = zyPtrBase + 2*zyIdx;
+  }
+
+  savedEnv = env;
+  double complex retval = zdotc_(&n, zxPtr, &incx, zyPtr, &incy);
+  if(zyPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zy, zyPtrBase, 0);
+    if (zyPtrBase == zxPtrBase)
+      zxPtrBase = 0;
+    zyPtrBase = 0;
+  }
+  if(zxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zx, zxPtrBase, 0);
+    zxPtrBase = 0;
+  }
+
+  return createComplexDouble(env, retval);
+}
+
+JNIEXPORT jobject JNICALL Java_org_jblas_NativeBlas_zdotu(JNIEnv *env, jclass this, jint n, jdoubleArray zx, jint zxIdx, jint incx, jdoubleArray zy, jint zyIdx, jint incy)
+{
+  extern double complex zdotu_(jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  jdouble *zxPtrBase = 0, *zxPtr = 0;
+  if (zx) {
+    zxPtrBase = (*env)->GetDoubleArrayElements(env, zx, NULL);
+    zxPtr = zxPtrBase + 2*zxIdx;
+  }
+  jdouble *zyPtrBase = 0, *zyPtr = 0;
+  if (zy) {
+    if((*env)->IsSameObject(env, zy, zx) == JNI_TRUE)
+      zyPtrBase = zxPtrBase;
+    else
+      zyPtrBase = (*env)->GetDoubleArrayElements(env, zy, NULL);
+    zyPtr = zyPtrBase + 2*zyIdx;
+  }
+
+  savedEnv = env;
+  double complex retval = zdotu_(&n, zxPtr, &incx, zyPtr, &incy);
+  if(zyPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zy, zyPtrBase, 0);
+    if (zyPtrBase == zxPtrBase)
+      zxPtrBase = 0;
+    zyPtrBase = 0;
+  }
+  if(zxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zx, zxPtrBase, 0);
+    zxPtrBase = 0;
+  }
+
+  return createComplexDouble(env, retval);
+}
+
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_dnrm2(JNIEnv *env, jclass this, jint n, jdoubleArray x, jint xIdx, jint incx)
+{
+  extern jdouble dnrm2_(jint *, jdouble *, jint *);
+  
+  jdouble *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetDoubleArrayElements(env, x, NULL);
+    xPtr = xPtrBase + xIdx;
+  }
+
+  savedEnv = env;
+  jdouble retval = dnrm2_(&n, xPtr, &incx);
+  if(xPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, x, xPtrBase, 0);
+    xPtrBase = 0;
+  }
+
+  return retval;
+}
+
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_dznrm2(JNIEnv *env, jclass this, jint n, jdoubleArray x, jint xIdx, jint incx)
+{
+  extern jdouble dznrm2_(jint *, jdouble *, jint *);
+  
+  jdouble *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetDoubleArrayElements(env, x, NULL);
+    xPtr = xPtrBase + 2*xIdx;
+  }
+
+  savedEnv = env;
+  jdouble retval = dznrm2_(&n, xPtr, &incx);
+  if(xPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, x, xPtrBase, 0);
+    xPtrBase = 0;
+  }
+
+  return retval;
+}
+
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_scnrm2(JNIEnv *env, jclass this, jint n, jfloatArray x, jint xIdx, jint incx)
+{
+  extern jfloat scnrm2_(jint *, jfloat *, jint *);
+  
+  jfloat *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetFloatArrayElements(env, x, NULL);
+    xPtr = xPtrBase + 2*xIdx;
+  }
+
+  savedEnv = env;
+  jfloat retval = scnrm2_(&n, xPtr, &incx);
+  if(xPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, x, xPtrBase, 0);
+    xPtrBase = 0;
+  }
+
+  return (jdouble) retval;
+}
+
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_snrm2(JNIEnv *env, jclass this, jint n, jfloatArray x, jint xIdx, jint incx)
+{
+  extern jfloat snrm2_(jint *, jfloat *, jint *);
+  
+  jfloat *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetFloatArrayElements(env, x, NULL);
+    xPtr = xPtrBase + xIdx;
+  }
+
+  savedEnv = env;
+  jfloat retval = snrm2_(&n, xPtr, &incx);
+  if(xPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, x, xPtrBase, 0);
+    xPtrBase = 0;
+  }
+
+  return (jdouble) retval;
+}
+
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_dasum(JNIEnv *env, jclass this, jint n, jdoubleArray dx, jint dxIdx, jint incx)
+{
+  extern jdouble dasum_(jint *, jdouble *, jint *);
+  
+  jdouble *dxPtrBase = 0, *dxPtr = 0;
+  if (dx) {
+    dxPtrBase = (*env)->GetDoubleArrayElements(env, dx, NULL);
+    dxPtr = dxPtrBase + dxIdx;
+  }
+
+  savedEnv = env;
+  jdouble retval = dasum_(&n, dxPtr, &incx);
+  if(dxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dx, dxPtrBase, 0);
+    dxPtrBase = 0;
+  }
+
+  return retval;
+}
+
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_dzasum(JNIEnv *env, jclass this, jint n, jdoubleArray zx, jint zxIdx, jint incx)
+{
+  extern jdouble dzasum_(jint *, jdouble *, jint *);
+  
+  jdouble *zxPtrBase = 0, *zxPtr = 0;
+  if (zx) {
+    zxPtrBase = (*env)->GetDoubleArrayElements(env, zx, NULL);
+    zxPtr = zxPtrBase + 2*zxIdx;
+  }
+
+  savedEnv = env;
+  jdouble retval = dzasum_(&n, zxPtr, &incx);
+  if(zxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zx, zxPtrBase, 0);
+    zxPtrBase = 0;
+  }
+
+  return retval;
+}
+
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_sasum(JNIEnv *env, jclass this, jint n, jfloatArray sx, jint sxIdx, jint incx)
+{
+  extern jfloat sasum_(jint *, jfloat *, jint *);
+  
+  jfloat *sxPtrBase = 0, *sxPtr = 0;
+  if (sx) {
+    sxPtrBase = (*env)->GetFloatArrayElements(env, sx, NULL);
+    sxPtr = sxPtrBase + sxIdx;
+  }
+
+  savedEnv = env;
+  jfloat retval = sasum_(&n, sxPtr, &incx);
+  if(sxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sx, sxPtrBase, 0);
+    sxPtrBase = 0;
+  }
+
+  return (jdouble) retval;
+}
+
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_scasum(JNIEnv *env, jclass this, jint n, jfloatArray cx, jint cxIdx, jint incx)
+{
+  extern jfloat scasum_(jint *, jfloat *, jint *);
+  
+  jfloat *cxPtrBase = 0, *cxPtr = 0;
+  if (cx) {
+    cxPtrBase = (*env)->GetFloatArrayElements(env, cx, NULL);
+    cxPtr = cxPtrBase + 2*cxIdx;
+  }
+
+  savedEnv = env;
+  jfloat retval = scasum_(&n, cxPtr, &incx);
+  if(cxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cx, cxPtrBase, 0);
+    cxPtrBase = 0;
+  }
+
+  return (jdouble) retval;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_icamax(JNIEnv *env, jclass this, jint n, jfloatArray cx, jint cxIdx, jint incx)
+{
+  extern jint icamax_(jint *, jfloat *, jint *);
+  
+  jfloat *cxPtrBase = 0, *cxPtr = 0;
+  if (cx) {
+    cxPtrBase = (*env)->GetFloatArrayElements(env, cx, NULL);
+    cxPtr = cxPtrBase + 2*cxIdx;
+  }
+
+  savedEnv = env;
+  jint retval = icamax_(&n, cxPtr, &incx);
+  if(cxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, cx, cxPtrBase, 0);
+    cxPtrBase = 0;
+  }
+
+  return retval;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_idamax(JNIEnv *env, jclass this, jint n, jdoubleArray dx, jint dxIdx, jint incx)
+{
+  extern jint idamax_(jint *, jdouble *, jint *);
+  
+  jdouble *dxPtrBase = 0, *dxPtr = 0;
+  if (dx) {
+    dxPtrBase = (*env)->GetDoubleArrayElements(env, dx, NULL);
+    dxPtr = dxPtrBase + dxIdx;
+  }
+
+  savedEnv = env;
+  jint retval = idamax_(&n, dxPtr, &incx);
+  if(dxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, dx, dxPtrBase, 0);
+    dxPtrBase = 0;
+  }
+
+  return retval;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_isamax(JNIEnv *env, jclass this, jint n, jfloatArray sx, jint sxIdx, jint incx)
+{
+  extern jint isamax_(jint *, jfloat *, jint *);
+  
+  jfloat *sxPtrBase = 0, *sxPtr = 0;
+  if (sx) {
+    sxPtrBase = (*env)->GetFloatArrayElements(env, sx, NULL);
+    sxPtr = sxPtrBase + sxIdx;
+  }
+
+  savedEnv = env;
+  jint retval = isamax_(&n, sxPtr, &incx);
+  if(sxPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, sx, sxPtrBase, 0);
+    sxPtrBase = 0;
+  }
+
+  return retval;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_izamax(JNIEnv *env, jclass this, jint n, jdoubleArray zx, jint zxIdx, jint incx)
+{
+  extern jint izamax_(jint *, jdouble *, jint *);
+  
+  jdouble *zxPtrBase = 0, *zxPtr = 0;
+  if (zx) {
+    zxPtrBase = (*env)->GetDoubleArrayElements(env, zx, NULL);
+    zxPtr = zxPtrBase + 2*zxIdx;
+  }
+
+  savedEnv = env;
+  jint retval = izamax_(&n, zxPtr, &incx);
+  if(zxPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, zx, zxPtrBase, 0);
+    zxPtrBase = 0;
+  }
+
+  return retval;
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cgemv(JNIEnv *env, jclass this, jchar trans, jint m, jint n, jobject alpha, jfloatArray a, jint aIdx, jint lda, jfloatArray x, jint xIdx, jint incx, jobject beta, jfloatArray y, jint yIdx, jint incy)
+{
+  extern void cgemv_(char *, jint *, jint *, float complex *, jfloat *, jint *, jfloat *, jint *, float complex *, jfloat *, jint *);
+  
+  char transChr = (char) trans;
+  float complex alphaCplx;
+  alphaCplx = getComplexFloat(env, alpha);
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+  jfloat *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    if((*env)->IsSameObject(env, x, a) == JNI_TRUE)
+      xPtrBase = aPtrBase;
+    else
+      xPtrBase = (*env)->GetFloatArrayElements(env, x, NULL);
+    xPtr = xPtrBase + 2*xIdx;
+  }
+  float complex betaCplx;
+  betaCplx = getComplexFloat(env, beta);
+  jfloat *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, a) == JNI_TRUE)
+      yPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetFloatArrayElements(env, y, NULL);
+    yPtr = yPtrBase + 2*yIdx;
+  }
+
+  savedEnv = env;
+  cgemv_(&transChr, &m, &n, &alphaCplx, aPtr, &lda, xPtr, &incx, &betaCplx, yPtr, &incy);
+  if(yPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, y, yPtrBase, 0);
+    if (yPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, x, xPtrBase, JNI_ABORT);
+    if (xPtrBase == aPtrBase)
+      aPtrBase = 0;
+    xPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, JNI_ABORT);
+    aPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dgemv(JNIEnv *env, jclass this, jchar trans, jint m, jint n, jdouble alpha, jdoubleArray a, jint aIdx, jint lda, jdoubleArray x, jint xIdx, jint incx, jdouble beta, jdoubleArray y, jint yIdx, jint incy)
+{
+  extern void dgemv_(char *, jint *, jint *, jdouble *, jdouble *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *);
+  
+  char transChr = (char) trans;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jdouble *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    if((*env)->IsSameObject(env, x, a) == JNI_TRUE)
+      xPtrBase = aPtrBase;
+    else
+      xPtrBase = (*env)->GetDoubleArrayElements(env, x, NULL);
+    xPtr = xPtrBase + xIdx;
+  }
+  jdouble *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, a) == JNI_TRUE)
+      yPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetDoubleArrayElements(env, y, NULL);
+    yPtr = yPtrBase + yIdx;
+  }
+
+  savedEnv = env;
+  dgemv_(&transChr, &m, &n, &alpha, aPtr, &lda, xPtr, &incx, &beta, yPtr, &incy);
+  if(yPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, y, yPtrBase, 0);
+    if (yPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, x, xPtrBase, JNI_ABORT);
+    if (xPtrBase == aPtrBase)
+      aPtrBase = 0;
+    xPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, JNI_ABORT);
+    aPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sgemv(JNIEnv *env, jclass this, jchar trans, jint m, jint n, jfloat alpha, jfloatArray a, jint aIdx, jint lda, jfloatArray x, jint xIdx, jint incx, jfloat beta, jfloatArray y, jint yIdx, jint incy)
+{
+  extern void sgemv_(char *, jint *, jint *, jfloat *, jfloat *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *);
+  
+  char transChr = (char) trans;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jfloat *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    if((*env)->IsSameObject(env, x, a) == JNI_TRUE)
+      xPtrBase = aPtrBase;
+    else
+      xPtrBase = (*env)->GetFloatArrayElements(env, x, NULL);
+    xPtr = xPtrBase + xIdx;
+  }
+  jfloat *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, a) == JNI_TRUE)
+      yPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetFloatArrayElements(env, y, NULL);
+    yPtr = yPtrBase + yIdx;
+  }
+
+  savedEnv = env;
+  sgemv_(&transChr, &m, &n, &alpha, aPtr, &lda, xPtr, &incx, &beta, yPtr, &incy);
+  if(yPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, y, yPtrBase, 0);
+    if (yPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, x, xPtrBase, JNI_ABORT);
+    if (xPtrBase == aPtrBase)
+      aPtrBase = 0;
+    xPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, JNI_ABORT);
+    aPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zgemv(JNIEnv *env, jclass this, jchar trans, jint m, jint n, jobject alpha, jdoubleArray a, jint aIdx, jint lda, jdoubleArray x, jint xIdx, jint incx, jobject beta, jdoubleArray y, jint yIdx, jint incy)
+{
+  extern void zgemv_(char *, jint *, jint *, double complex *, jdouble *, jint *, jdouble *, jint *, double complex *, jdouble *, jint *);
+  
+  char transChr = (char) trans;
+  double complex alphaCplx;
+  alphaCplx = getComplexDouble(env, alpha);
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+  jdouble *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    if((*env)->IsSameObject(env, x, a) == JNI_TRUE)
+      xPtrBase = aPtrBase;
+    else
+      xPtrBase = (*env)->GetDoubleArrayElements(env, x, NULL);
+    xPtr = xPtrBase + 2*xIdx;
+  }
+  double complex betaCplx;
+  betaCplx = getComplexDouble(env, beta);
+  jdouble *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, a) == JNI_TRUE)
+      yPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetDoubleArrayElements(env, y, NULL);
+    yPtr = yPtrBase + 2*yIdx;
+  }
+
+  savedEnv = env;
+  zgemv_(&transChr, &m, &n, &alphaCplx, aPtr, &lda, xPtr, &incx, &betaCplx, yPtr, &incy);
+  if(yPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, y, yPtrBase, 0);
+    if (yPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, x, xPtrBase, JNI_ABORT);
+    if (xPtrBase == aPtrBase)
+      aPtrBase = 0;
+    xPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, JNI_ABORT);
+    aPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cgerc(JNIEnv *env, jclass this, jint m, jint n, jobject alpha, jfloatArray x, jint xIdx, jint incx, jfloatArray y, jint yIdx, jint incy, jfloatArray a, jint aIdx, jint lda)
+{
+  extern void cgerc_(jint *, jint *, float complex *, jfloat *, jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  float complex alphaCplx;
+  alphaCplx = getComplexFloat(env, alpha);
+  jfloat *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetFloatArrayElements(env, x, NULL);
+    xPtr = xPtrBase + 2*xIdx;
+  }
+  jfloat *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetFloatArrayElements(env, y, NULL);
+    yPtr = yPtrBase + 2*yIdx;
+  }
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, x) == JNI_TRUE)
+      aPtrBase = xPtrBase;
+    else
+      if((*env)->IsSameObject(env, a, y) == JNI_TRUE)
+      aPtrBase = yPtrBase;
+    else
+      aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+
+  savedEnv = env;
+  cgerc_(&m, &n, &alphaCplx, xPtr, &incx, yPtr, &incy, aPtr, &lda);
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == xPtrBase)
+      xPtrBase = 0;
+    if (aPtrBase == yPtrBase)
+      yPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(yPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, y, yPtrBase, JNI_ABORT);
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, x, xPtrBase, JNI_ABORT);
+    xPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cgeru(JNIEnv *env, jclass this, jint m, jint n, jobject alpha, jfloatArray x, jint xIdx, jint incx, jfloatArray y, jint yIdx, jint incy, jfloatArray a, jint aIdx, jint lda)
+{
+  extern void cgeru_(jint *, jint *, float complex *, jfloat *, jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  float complex alphaCplx;
+  alphaCplx = getComplexFloat(env, alpha);
+  jfloat *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetFloatArrayElements(env, x, NULL);
+    xPtr = xPtrBase + 2*xIdx;
+  }
+  jfloat *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetFloatArrayElements(env, y, NULL);
+    yPtr = yPtrBase + 2*yIdx;
+  }
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, x) == JNI_TRUE)
+      aPtrBase = xPtrBase;
+    else
+      if((*env)->IsSameObject(env, a, y) == JNI_TRUE)
+      aPtrBase = yPtrBase;
+    else
+      aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+
+  savedEnv = env;
+  cgeru_(&m, &n, &alphaCplx, xPtr, &incx, yPtr, &incy, aPtr, &lda);
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == xPtrBase)
+      xPtrBase = 0;
+    if (aPtrBase == yPtrBase)
+      yPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(yPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, y, yPtrBase, JNI_ABORT);
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, x, xPtrBase, JNI_ABORT);
+    xPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dger(JNIEnv *env, jclass this, jint m, jint n, jdouble alpha, jdoubleArray x, jint xIdx, jint incx, jdoubleArray y, jint yIdx, jint incy, jdoubleArray a, jint aIdx, jint lda)
+{
+  extern void dger_(jint *, jint *, jdouble *, jdouble *, jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  jdouble *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetDoubleArrayElements(env, x, NULL);
+    xPtr = xPtrBase + xIdx;
+  }
+  jdouble *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetDoubleArrayElements(env, y, NULL);
+    yPtr = yPtrBase + yIdx;
+  }
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, x) == JNI_TRUE)
+      aPtrBase = xPtrBase;
+    else
+      if((*env)->IsSameObject(env, a, y) == JNI_TRUE)
+      aPtrBase = yPtrBase;
+    else
+      aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+
+  savedEnv = env;
+  dger_(&m, &n, &alpha, xPtr, &incx, yPtr, &incy, aPtr, &lda);
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == xPtrBase)
+      xPtrBase = 0;
+    if (aPtrBase == yPtrBase)
+      yPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(yPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, y, yPtrBase, JNI_ABORT);
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, x, xPtrBase, JNI_ABORT);
+    xPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sger(JNIEnv *env, jclass this, jint m, jint n, jfloat alpha, jfloatArray x, jint xIdx, jint incx, jfloatArray y, jint yIdx, jint incy, jfloatArray a, jint aIdx, jint lda)
+{
+  extern void sger_(jint *, jint *, jfloat *, jfloat *, jint *, jfloat *, jint *, jfloat *, jint *);
+  
+  jfloat *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetFloatArrayElements(env, x, NULL);
+    xPtr = xPtrBase + xIdx;
+  }
+  jfloat *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetFloatArrayElements(env, y, NULL);
+    yPtr = yPtrBase + yIdx;
+  }
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, x) == JNI_TRUE)
+      aPtrBase = xPtrBase;
+    else
+      if((*env)->IsSameObject(env, a, y) == JNI_TRUE)
+      aPtrBase = yPtrBase;
+    else
+      aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+
+  savedEnv = env;
+  sger_(&m, &n, &alpha, xPtr, &incx, yPtr, &incy, aPtr, &lda);
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == xPtrBase)
+      xPtrBase = 0;
+    if (aPtrBase == yPtrBase)
+      yPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(yPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, y, yPtrBase, JNI_ABORT);
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, x, xPtrBase, JNI_ABORT);
+    xPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zgerc(JNIEnv *env, jclass this, jint m, jint n, jobject alpha, jdoubleArray x, jint xIdx, jint incx, jdoubleArray y, jint yIdx, jint incy, jdoubleArray a, jint aIdx, jint lda)
+{
+  extern void zgerc_(jint *, jint *, double complex *, jdouble *, jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  double complex alphaCplx;
+  alphaCplx = getComplexDouble(env, alpha);
+  jdouble *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetDoubleArrayElements(env, x, NULL);
+    xPtr = xPtrBase + 2*xIdx;
+  }
+  jdouble *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetDoubleArrayElements(env, y, NULL);
+    yPtr = yPtrBase + 2*yIdx;
+  }
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, x) == JNI_TRUE)
+      aPtrBase = xPtrBase;
+    else
+      if((*env)->IsSameObject(env, a, y) == JNI_TRUE)
+      aPtrBase = yPtrBase;
+    else
+      aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+
+  savedEnv = env;
+  zgerc_(&m, &n, &alphaCplx, xPtr, &incx, yPtr, &incy, aPtr, &lda);
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == xPtrBase)
+      xPtrBase = 0;
+    if (aPtrBase == yPtrBase)
+      yPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(yPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, y, yPtrBase, JNI_ABORT);
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, x, xPtrBase, JNI_ABORT);
+    xPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zgeru(JNIEnv *env, jclass this, jint m, jint n, jobject alpha, jdoubleArray x, jint xIdx, jint incx, jdoubleArray y, jint yIdx, jint incy, jdoubleArray a, jint aIdx, jint lda)
+{
+  extern void zgeru_(jint *, jint *, double complex *, jdouble *, jint *, jdouble *, jint *, jdouble *, jint *);
+  
+  double complex alphaCplx;
+  alphaCplx = getComplexDouble(env, alpha);
+  jdouble *xPtrBase = 0, *xPtr = 0;
+  if (x) {
+    xPtrBase = (*env)->GetDoubleArrayElements(env, x, NULL);
+    xPtr = xPtrBase + 2*xIdx;
+  }
+  jdouble *yPtrBase = 0, *yPtr = 0;
+  if (y) {
+    if((*env)->IsSameObject(env, y, x) == JNI_TRUE)
+      yPtrBase = xPtrBase;
+    else
+      yPtrBase = (*env)->GetDoubleArrayElements(env, y, NULL);
+    yPtr = yPtrBase + 2*yIdx;
+  }
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, x) == JNI_TRUE)
+      aPtrBase = xPtrBase;
+    else
+      if((*env)->IsSameObject(env, a, y) == JNI_TRUE)
+      aPtrBase = yPtrBase;
+    else
+      aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+
+  savedEnv = env;
+  zgeru_(&m, &n, &alphaCplx, xPtr, &incx, yPtr, &incy, aPtr, &lda);
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == xPtrBase)
+      xPtrBase = 0;
+    if (aPtrBase == yPtrBase)
+      yPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(yPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, y, yPtrBase, JNI_ABORT);
+    if (yPtrBase == xPtrBase)
+      xPtrBase = 0;
+    yPtrBase = 0;
+  }
+  if(xPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, x, xPtrBase, JNI_ABORT);
+    xPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cgemm(JNIEnv *env, jclass this, jchar transa, jchar transb, jint m, jint n, jint k, jobject alpha, jfloatArray a, jint aIdx, jint lda, jfloatArray b, jint bIdx, jint ldb, jobject beta, jfloatArray c, jint cIdx, jint ldc)
+{
+  extern void cgemm_(char *, char *, jint *, jint *, jint *, float complex *, jfloat *, jint *, jfloat *, jint *, float complex *, jfloat *, jint *);
+  
+  char transaChr = (char) transa;
+  char transbChr = (char) transb;
+  float complex alphaCplx;
+  alphaCplx = getComplexFloat(env, alpha);
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+  jfloat *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetFloatArrayElements(env, b, NULL);
+    bPtr = bPtrBase + 2*bIdx;
+  }
+  float complex betaCplx;
+  betaCplx = getComplexFloat(env, beta);
+  jfloat *cPtrBase = 0, *cPtr = 0;
+  if (c) {
+    if((*env)->IsSameObject(env, c, a) == JNI_TRUE)
+      cPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, c, b) == JNI_TRUE)
+      cPtrBase = bPtrBase;
+    else
+      cPtrBase = (*env)->GetFloatArrayElements(env, c, NULL);
+    cPtr = cPtrBase + 2*cIdx;
+  }
+
+  savedEnv = env;
+  cgemm_(&transaChr, &transbChr, &m, &n, &k, &alphaCplx, aPtr, &lda, bPtr, &ldb, &betaCplx, cPtr, &ldc);
+  if(cPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, c, cPtrBase, 0);
+    if (cPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (cPtrBase == bPtrBase)
+      bPtrBase = 0;
+    cPtrBase = 0;
+  }
+  if(bPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, b, bPtrBase, JNI_ABORT);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, JNI_ABORT);
+    aPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dgemm(JNIEnv *env, jclass this, jchar transa, jchar transb, jint m, jint n, jint k, jdouble alpha, jdoubleArray a, jint aIdx, jint lda, jdoubleArray b, jint bIdx, jint ldb, jdouble beta, jdoubleArray c, jint cIdx, jint ldc)
+{
+  extern void dgemm_(char *, char *, jint *, jint *, jint *, jdouble *, jdouble *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *);
+  
+  char transaChr = (char) transa;
+  char transbChr = (char) transb;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jdouble *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetDoubleArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  jdouble *cPtrBase = 0, *cPtr = 0;
+  if (c) {
+    if((*env)->IsSameObject(env, c, a) == JNI_TRUE)
+      cPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, c, b) == JNI_TRUE)
+      cPtrBase = bPtrBase;
+    else
+      cPtrBase = (*env)->GetDoubleArrayElements(env, c, NULL);
+    cPtr = cPtrBase + cIdx;
+  }
+
+  savedEnv = env;
+  dgemm_(&transaChr, &transbChr, &m, &n, &k, &alpha, aPtr, &lda, bPtr, &ldb, &beta, cPtr, &ldc);
+  if(cPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, c, cPtrBase, 0);
+    if (cPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (cPtrBase == bPtrBase)
+      bPtrBase = 0;
+    cPtrBase = 0;
+  }
+  if(bPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, b, bPtrBase, JNI_ABORT);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, JNI_ABORT);
+    aPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sgemm(JNIEnv *env, jclass this, jchar transa, jchar transb, jint m, jint n, jint k, jfloat alpha, jfloatArray a, jint aIdx, jint lda, jfloatArray b, jint bIdx, jint ldb, jfloat beta, jfloatArray c, jint cIdx, jint ldc)
+{
+  extern void sgemm_(char *, char *, jint *, jint *, jint *, jfloat *, jfloat *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *);
+  
+  char transaChr = (char) transa;
+  char transbChr = (char) transb;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jfloat *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetFloatArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  jfloat *cPtrBase = 0, *cPtr = 0;
+  if (c) {
+    if((*env)->IsSameObject(env, c, a) == JNI_TRUE)
+      cPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, c, b) == JNI_TRUE)
+      cPtrBase = bPtrBase;
+    else
+      cPtrBase = (*env)->GetFloatArrayElements(env, c, NULL);
+    cPtr = cPtrBase + cIdx;
+  }
+
+  savedEnv = env;
+  sgemm_(&transaChr, &transbChr, &m, &n, &k, &alpha, aPtr, &lda, bPtr, &ldb, &beta, cPtr, &ldc);
+  if(cPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, c, cPtrBase, 0);
+    if (cPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (cPtrBase == bPtrBase)
+      bPtrBase = 0;
+    cPtrBase = 0;
+  }
+  if(bPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, b, bPtrBase, JNI_ABORT);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, JNI_ABORT);
+    aPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zgemm(JNIEnv *env, jclass this, jchar transa, jchar transb, jint m, jint n, jint k, jobject alpha, jdoubleArray a, jint aIdx, jint lda, jdoubleArray b, jint bIdx, jint ldb, jobject beta, jdoubleArray c, jint cIdx, jint ldc)
+{
+  extern void zgemm_(char *, char *, jint *, jint *, jint *, double complex *, jdouble *, jint *, jdouble *, jint *, double complex *, jdouble *, jint *);
+  
+  char transaChr = (char) transa;
+  char transbChr = (char) transb;
+  double complex alphaCplx;
+  alphaCplx = getComplexDouble(env, alpha);
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+  jdouble *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetDoubleArrayElements(env, b, NULL);
+    bPtr = bPtrBase + 2*bIdx;
+  }
+  double complex betaCplx;
+  betaCplx = getComplexDouble(env, beta);
+  jdouble *cPtrBase = 0, *cPtr = 0;
+  if (c) {
+    if((*env)->IsSameObject(env, c, a) == JNI_TRUE)
+      cPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, c, b) == JNI_TRUE)
+      cPtrBase = bPtrBase;
+    else
+      cPtrBase = (*env)->GetDoubleArrayElements(env, c, NULL);
+    cPtr = cPtrBase + 2*cIdx;
+  }
+
+  savedEnv = env;
+  zgemm_(&transaChr, &transbChr, &m, &n, &k, &alphaCplx, aPtr, &lda, bPtr, &ldb, &betaCplx, cPtr, &ldc);
+  if(cPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, c, cPtrBase, 0);
+    if (cPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (cPtrBase == bPtrBase)
+      bPtrBase = 0;
+    cPtrBase = 0;
+  }
+  if(bPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, b, bPtrBase, JNI_ABORT);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, JNI_ABORT);
+    aPtrBase = 0;
+  }
+
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dgesv(JNIEnv *env, jclass this, jint n, jint nrhs, jdoubleArray a, jint aIdx, jint lda, jintArray ipiv, jint ipivIdx, jdoubleArray b, jint bIdx, jint ldb)
+{
+  extern void dgesv_(jint *, jint *, jdouble *, jint *, jint *, jdouble *, jint *, int *);
+  
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *ipivPtrBase = 0, *ipivPtr = 0;
+  if (ipiv) {
+    ipivPtrBase = (*env)->GetIntArrayElements(env, ipiv, NULL);
+    ipivPtr = ipivPtrBase + ipivIdx;
+  }
+  jdouble *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetDoubleArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dgesv_(&n, &nrhs, aPtr, &lda, ipivPtr, bPtr, &ldb, &info);
+  if(bPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, b, bPtrBase, 0);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(ipivPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, ipiv, ipivPtrBase, 0);
+    ipivPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sgesv(JNIEnv *env, jclass this, jint n, jint nrhs, jfloatArray a, jint aIdx, jint lda, jintArray ipiv, jint ipivIdx, jfloatArray b, jint bIdx, jint ldb)
+{
+  extern void sgesv_(jint *, jint *, jfloat *, jint *, jint *, jfloat *, jint *, int *);
+  
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *ipivPtrBase = 0, *ipivPtr = 0;
+  if (ipiv) {
+    ipivPtrBase = (*env)->GetIntArrayElements(env, ipiv, NULL);
+    ipivPtr = ipivPtrBase + ipivIdx;
+  }
+  jfloat *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetFloatArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  sgesv_(&n, &nrhs, aPtr, &lda, ipivPtr, bPtr, &ldb, &info);
+  if(bPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, b, bPtrBase, 0);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(ipivPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, ipiv, ipivPtrBase, 0);
+    ipivPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsysv(JNIEnv *env, jclass this, jchar uplo, jint n, jint nrhs, jdoubleArray a, jint aIdx, jint lda, jintArray ipiv, jint ipivIdx, jdoubleArray b, jint bIdx, jint ldb, jdoubleArray work, jint workIdx, jint lwork)
+{
+  extern void dsysv_(char *, jint *, jint *, jdouble *, jint *, jint *, jdouble *, jint *, jdouble *, jint *, int *);
+  
+  char uploChr = (char) uplo;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *ipivPtrBase = 0, *ipivPtr = 0;
+  if (ipiv) {
+    ipivPtrBase = (*env)->GetIntArrayElements(env, ipiv, NULL);
+    ipivPtr = ipivPtrBase + ipivIdx;
+  }
+  jdouble *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetDoubleArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, b) == JNI_TRUE)
+      workPtrBase = bPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dsysv_(&uploChr, &n, &nrhs, aPtr, &lda, ipivPtr, bPtr, &ldb, workPtr, &lwork, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == bPtrBase)
+      bPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(bPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, b, bPtrBase, 0);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(ipivPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, ipiv, ipivPtrBase, 0);
+    ipivPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssysv(JNIEnv *env, jclass this, jchar uplo, jint n, jint nrhs, jfloatArray a, jint aIdx, jint lda, jintArray ipiv, jint ipivIdx, jfloatArray b, jint bIdx, jint ldb, jfloatArray work, jint workIdx, jint lwork)
+{
+  extern void ssysv_(char *, jint *, jint *, jfloat *, jint *, jint *, jfloat *, jint *, jfloat *, jint *, int *);
+  
+  char uploChr = (char) uplo;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *ipivPtrBase = 0, *ipivPtr = 0;
+  if (ipiv) {
+    ipivPtrBase = (*env)->GetIntArrayElements(env, ipiv, NULL);
+    ipivPtr = ipivPtrBase + ipivIdx;
+  }
+  jfloat *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetFloatArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, b) == JNI_TRUE)
+      workPtrBase = bPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  ssysv_(&uploChr, &n, &nrhs, aPtr, &lda, ipivPtr, bPtr, &ldb, workPtr, &lwork, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == bPtrBase)
+      bPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(bPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, b, bPtrBase, 0);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(ipivPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, ipiv, ipivPtrBase, 0);
+    ipivPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsyev(JNIEnv *env, jclass this, jchar jobz, jchar uplo, jint n, jdoubleArray a, jint aIdx, jint lda, jdoubleArray w, jint wIdx, jdoubleArray work, jint workIdx, jint lwork)
+{
+  extern void dsyev_(char *, char *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char uploChr = (char) uplo;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jdouble *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetDoubleArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dsyev_(&jobzChr, &uploChr, &n, aPtr, &lda, wPtr, workPtr, &lwork, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssyev(JNIEnv *env, jclass this, jchar jobz, jchar uplo, jint n, jfloatArray a, jint aIdx, jint lda, jfloatArray w, jint wIdx, jfloatArray work, jint workIdx, jint lwork)
+{
+  extern void ssyev_(char *, char *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char uploChr = (char) uplo;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jfloat *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetFloatArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  ssyev_(&jobzChr, &uploChr, &n, aPtr, &lda, wPtr, workPtr, &lwork, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsyevd(JNIEnv *env, jclass this, jchar jobz, jchar uplo, jint n, jdoubleArray a, jint aIdx, jint lda, jdoubleArray w, jint wIdx, jdoubleArray work, jint workIdx, jint lwork, jintArray iwork, jint iworkIdx, jint liwork)
+{
+  extern void dsyevd_(char *, char *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, jint *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char uploChr = (char) uplo;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jdouble *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetDoubleArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  jint *iworkPtrBase = 0, *iworkPtr = 0;
+  if (iwork) {
+    iworkPtrBase = (*env)->GetIntArrayElements(env, iwork, NULL);
+    iworkPtr = iworkPtrBase + iworkIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dsyevd_(&jobzChr, &uploChr, &n, aPtr, &lda, wPtr, workPtr, &lwork, iworkPtr, &liwork, &info);
+  if(iworkPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, iwork, iworkPtrBase, 0);
+    iworkPtrBase = 0;
+  }
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsyevr(JNIEnv *env, jclass this, jchar jobz, jchar range, jchar uplo, jint n, jdoubleArray a, jint aIdx, jint lda, jdouble vl, jdouble vu, jint il, jint iu, jdouble abstol, jintArray m, jint mIdx, jdoubleArray w, jint wIdx, jdoubleArray z, jint zIdx, jint ldz, jintArray isuppz, jint isuppzIdx, jdoubleArray work, jint workIdx, jint lwork, jintArray iwork, jint iworkIdx, jint liwork)
+{
+  extern void dsyevr_(char *, char *, char *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, jint *, jdouble *, jint *, jint *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char rangeChr = (char) range;
+  char uploChr = (char) uplo;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *mPtrBase = 0, *mPtr = 0;
+  if (m) {
+    mPtrBase = (*env)->GetIntArrayElements(env, m, NULL);
+    mPtr = mPtrBase + mIdx;
+  }
+  jdouble *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetDoubleArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jdouble *zPtrBase = 0, *zPtr = 0;
+  if (z) {
+    if((*env)->IsSameObject(env, z, a) == JNI_TRUE)
+      zPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, z, w) == JNI_TRUE)
+      zPtrBase = wPtrBase;
+    else
+      zPtrBase = (*env)->GetDoubleArrayElements(env, z, NULL);
+    zPtr = zPtrBase + zIdx;
+  }
+  jint *isuppzPtrBase = 0, *isuppzPtr = 0;
+  if (isuppz) {
+    if((*env)->IsSameObject(env, isuppz, m) == JNI_TRUE)
+      isuppzPtrBase = mPtrBase;
+    else
+      isuppzPtrBase = (*env)->GetIntArrayElements(env, isuppz, NULL);
+    isuppzPtr = isuppzPtrBase + isuppzIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, z) == JNI_TRUE)
+      workPtrBase = zPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  jint *iworkPtrBase = 0, *iworkPtr = 0;
+  if (iwork) {
+    if((*env)->IsSameObject(env, iwork, m) == JNI_TRUE)
+      iworkPtrBase = mPtrBase;
+    else
+      if((*env)->IsSameObject(env, iwork, isuppz) == JNI_TRUE)
+      iworkPtrBase = isuppzPtrBase;
+    else
+      iworkPtrBase = (*env)->GetIntArrayElements(env, iwork, NULL);
+    iworkPtr = iworkPtrBase + iworkIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dsyevr_(&jobzChr, &rangeChr, &uploChr, &n, aPtr, &lda, &vl, &vu, &il, &iu, &abstol, mPtr, wPtr, zPtr, &ldz, isuppzPtr, workPtr, &lwork, iworkPtr, &liwork, &info);
+  if(iworkPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, iwork, iworkPtrBase, 0);
+    if (iworkPtrBase == mPtrBase)
+      mPtrBase = 0;
+    if (iworkPtrBase == isuppzPtrBase)
+      isuppzPtrBase = 0;
+    iworkPtrBase = 0;
+  }
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    if (workPtrBase == zPtrBase)
+      zPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(isuppzPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, isuppz, isuppzPtrBase, 0);
+    if (isuppzPtrBase == mPtrBase)
+      mPtrBase = 0;
+    isuppzPtrBase = 0;
+  }
+  if(zPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, z, zPtrBase, 0);
+    if (zPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (zPtrBase == wPtrBase)
+      wPtrBase = 0;
+    zPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(mPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, m, mPtrBase, 0);
+    mPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsyevx(JNIEnv *env, jclass this, jchar jobz, jchar range, jchar uplo, jint n, jdoubleArray a, jint aIdx, jint lda, jdouble vl, jdouble vu, jint il, jint iu, jdouble abstol, jintArray m, jint mIdx, jdoubleArray w, jint wIdx, jdoubleArray z, jint zIdx, jint ldz, jdoubleArray work, jint workIdx, jint lwork, jintArray iwork, jint iworkIdx, jintArray ifail, jint ifailIdx)
+{
+  extern void dsyevx_(char *, char *, char *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, jdouble *, jint *, jint *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char rangeChr = (char) range;
+  char uploChr = (char) uplo;
+  jint *iworkPtrBase = 0, *iworkPtr = 0;
+  if (iwork) {
+    iworkPtrBase = (*env)->GetIntArrayElements(env, iwork, NULL);
+    iworkPtr = iworkPtrBase + iworkIdx;
+  }
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *mPtrBase = 0, *mPtr = 0;
+  if (m) {
+    if((*env)->IsSameObject(env, m, iwork) == JNI_TRUE)
+      mPtrBase = iworkPtrBase;
+    else
+      mPtrBase = (*env)->GetIntArrayElements(env, m, NULL);
+    mPtr = mPtrBase + mIdx;
+  }
+  jdouble *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetDoubleArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jdouble *zPtrBase = 0, *zPtr = 0;
+  if (z) {
+    if((*env)->IsSameObject(env, z, a) == JNI_TRUE)
+      zPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, z, w) == JNI_TRUE)
+      zPtrBase = wPtrBase;
+    else
+      zPtrBase = (*env)->GetDoubleArrayElements(env, z, NULL);
+    zPtr = zPtrBase + zIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, z) == JNI_TRUE)
+      workPtrBase = zPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  jint *ifailPtrBase = 0, *ifailPtr = 0;
+  if (ifail) {
+    if((*env)->IsSameObject(env, ifail, iwork) == JNI_TRUE)
+      ifailPtrBase = iworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, ifail, m) == JNI_TRUE)
+      ifailPtrBase = mPtrBase;
+    else
+      ifailPtrBase = (*env)->GetIntArrayElements(env, ifail, NULL);
+    ifailPtr = ifailPtrBase + ifailIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dsyevx_(&jobzChr, &rangeChr, &uploChr, &n, aPtr, &lda, &vl, &vu, &il, &iu, &abstol, mPtr, wPtr, zPtr, &ldz, workPtr, &lwork, iworkPtr, ifailPtr, &info);
+  if(ifailPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, ifail, ifailPtrBase, 0);
+    if (ifailPtrBase == iworkPtrBase)
+      iworkPtrBase = 0;
+    if (ifailPtrBase == mPtrBase)
+      mPtrBase = 0;
+    ifailPtrBase = 0;
+  }
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    if (workPtrBase == zPtrBase)
+      zPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(zPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, z, zPtrBase, 0);
+    if (zPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (zPtrBase == wPtrBase)
+      wPtrBase = 0;
+    zPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(mPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, m, mPtrBase, 0);
+    if (mPtrBase == iworkPtrBase)
+      iworkPtrBase = 0;
+    mPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+  if(iworkPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, iwork, iworkPtrBase, JNI_ABORT);
+    iworkPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssyevd(JNIEnv *env, jclass this, jchar jobz, jchar uplo, jint n, jfloatArray a, jint aIdx, jint lda, jfloatArray w, jint wIdx, jfloatArray work, jint workIdx, jint lwork, jintArray iwork, jint iworkIdx, jint liwork)
+{
+  extern void ssyevd_(char *, char *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, jint *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char uploChr = (char) uplo;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jfloat *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetFloatArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  jint *iworkPtrBase = 0, *iworkPtr = 0;
+  if (iwork) {
+    iworkPtrBase = (*env)->GetIntArrayElements(env, iwork, NULL);
+    iworkPtr = iworkPtrBase + iworkIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  ssyevd_(&jobzChr, &uploChr, &n, aPtr, &lda, wPtr, workPtr, &lwork, iworkPtr, &liwork, &info);
+  if(iworkPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, iwork, iworkPtrBase, 0);
+    iworkPtrBase = 0;
+  }
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssyevr(JNIEnv *env, jclass this, jchar jobz, jchar range, jchar uplo, jint n, jfloatArray a, jint aIdx, jint lda, jfloat vl, jfloat vu, jint il, jint iu, jfloat abstol, jintArray m, jint mIdx, jfloatArray w, jint wIdx, jfloatArray z, jint zIdx, jint ldz, jintArray isuppz, jint isuppzIdx, jfloatArray work, jint workIdx, jint lwork, jintArray iwork, jint iworkIdx, jint liwork)
+{
+  extern void ssyevr_(char *, char *, char *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, jint *, jfloat *, jint *, jint *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char rangeChr = (char) range;
+  char uploChr = (char) uplo;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *mPtrBase = 0, *mPtr = 0;
+  if (m) {
+    mPtrBase = (*env)->GetIntArrayElements(env, m, NULL);
+    mPtr = mPtrBase + mIdx;
+  }
+  jfloat *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetFloatArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jfloat *zPtrBase = 0, *zPtr = 0;
+  if (z) {
+    if((*env)->IsSameObject(env, z, a) == JNI_TRUE)
+      zPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, z, w) == JNI_TRUE)
+      zPtrBase = wPtrBase;
+    else
+      zPtrBase = (*env)->GetFloatArrayElements(env, z, NULL);
+    zPtr = zPtrBase + zIdx;
+  }
+  jint *isuppzPtrBase = 0, *isuppzPtr = 0;
+  if (isuppz) {
+    if((*env)->IsSameObject(env, isuppz, m) == JNI_TRUE)
+      isuppzPtrBase = mPtrBase;
+    else
+      isuppzPtrBase = (*env)->GetIntArrayElements(env, isuppz, NULL);
+    isuppzPtr = isuppzPtrBase + isuppzIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, z) == JNI_TRUE)
+      workPtrBase = zPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  jint *iworkPtrBase = 0, *iworkPtr = 0;
+  if (iwork) {
+    if((*env)->IsSameObject(env, iwork, m) == JNI_TRUE)
+      iworkPtrBase = mPtrBase;
+    else
+      if((*env)->IsSameObject(env, iwork, isuppz) == JNI_TRUE)
+      iworkPtrBase = isuppzPtrBase;
+    else
+      iworkPtrBase = (*env)->GetIntArrayElements(env, iwork, NULL);
+    iworkPtr = iworkPtrBase + iworkIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  ssyevr_(&jobzChr, &rangeChr, &uploChr, &n, aPtr, &lda, &vl, &vu, &il, &iu, &abstol, mPtr, wPtr, zPtr, &ldz, isuppzPtr, workPtr, &lwork, iworkPtr, &liwork, &info);
+  if(iworkPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, iwork, iworkPtrBase, 0);
+    if (iworkPtrBase == mPtrBase)
+      mPtrBase = 0;
+    if (iworkPtrBase == isuppzPtrBase)
+      isuppzPtrBase = 0;
+    iworkPtrBase = 0;
+  }
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    if (workPtrBase == zPtrBase)
+      zPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(isuppzPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, isuppz, isuppzPtrBase, 0);
+    if (isuppzPtrBase == mPtrBase)
+      mPtrBase = 0;
+    isuppzPtrBase = 0;
+  }
+  if(zPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, z, zPtrBase, 0);
+    if (zPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (zPtrBase == wPtrBase)
+      wPtrBase = 0;
+    zPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(mPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, m, mPtrBase, 0);
+    mPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssyevx(JNIEnv *env, jclass this, jchar jobz, jchar range, jchar uplo, jint n, jfloatArray a, jint aIdx, jint lda, jfloat vl, jfloat vu, jint il, jint iu, jfloat abstol, jintArray m, jint mIdx, jfloatArray w, jint wIdx, jfloatArray z, jint zIdx, jint ldz, jfloatArray work, jint workIdx, jint lwork, jintArray iwork, jint iworkIdx, jintArray ifail, jint ifailIdx)
+{
+  extern void ssyevx_(char *, char *, char *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, jfloat *, jint *, jint *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char rangeChr = (char) range;
+  char uploChr = (char) uplo;
+  jint *iworkPtrBase = 0, *iworkPtr = 0;
+  if (iwork) {
+    iworkPtrBase = (*env)->GetIntArrayElements(env, iwork, NULL);
+    iworkPtr = iworkPtrBase + iworkIdx;
+  }
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *mPtrBase = 0, *mPtr = 0;
+  if (m) {
+    if((*env)->IsSameObject(env, m, iwork) == JNI_TRUE)
+      mPtrBase = iworkPtrBase;
+    else
+      mPtrBase = (*env)->GetIntArrayElements(env, m, NULL);
+    mPtr = mPtrBase + mIdx;
+  }
+  jfloat *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetFloatArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jfloat *zPtrBase = 0, *zPtr = 0;
+  if (z) {
+    if((*env)->IsSameObject(env, z, a) == JNI_TRUE)
+      zPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, z, w) == JNI_TRUE)
+      zPtrBase = wPtrBase;
+    else
+      zPtrBase = (*env)->GetFloatArrayElements(env, z, NULL);
+    zPtr = zPtrBase + zIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, z) == JNI_TRUE)
+      workPtrBase = zPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  jint *ifailPtrBase = 0, *ifailPtr = 0;
+  if (ifail) {
+    if((*env)->IsSameObject(env, ifail, iwork) == JNI_TRUE)
+      ifailPtrBase = iworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, ifail, m) == JNI_TRUE)
+      ifailPtrBase = mPtrBase;
+    else
+      ifailPtrBase = (*env)->GetIntArrayElements(env, ifail, NULL);
+    ifailPtr = ifailPtrBase + ifailIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  ssyevx_(&jobzChr, &rangeChr, &uploChr, &n, aPtr, &lda, &vl, &vu, &il, &iu, &abstol, mPtr, wPtr, zPtr, &ldz, workPtr, &lwork, iworkPtr, ifailPtr, &info);
+  if(ifailPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, ifail, ifailPtrBase, 0);
+    if (ifailPtrBase == iworkPtrBase)
+      iworkPtrBase = 0;
+    if (ifailPtrBase == mPtrBase)
+      mPtrBase = 0;
+    ifailPtrBase = 0;
+  }
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    if (workPtrBase == zPtrBase)
+      zPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(zPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, z, zPtrBase, 0);
+    if (zPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (zPtrBase == wPtrBase)
+      wPtrBase = 0;
+    zPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(mPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, m, mPtrBase, 0);
+    if (mPtrBase == iworkPtrBase)
+      iworkPtrBase = 0;
+    mPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+  if(iworkPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, iwork, iworkPtrBase, JNI_ABORT);
+    iworkPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dposv(JNIEnv *env, jclass this, jchar uplo, jint n, jint nrhs, jdoubleArray a, jint aIdx, jint lda, jdoubleArray b, jint bIdx, jint ldb)
+{
+  extern void dposv_(char *, jint *, jint *, jdouble *, jint *, jdouble *, jint *, int *);
+  
+  char uploChr = (char) uplo;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jdouble *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetDoubleArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dposv_(&uploChr, &n, &nrhs, aPtr, &lda, bPtr, &ldb, &info);
+  if(bPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, b, bPtrBase, 0);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sposv(JNIEnv *env, jclass this, jchar uplo, jint n, jint nrhs, jfloatArray a, jint aIdx, jint lda, jfloatArray b, jint bIdx, jint ldb)
+{
+  extern void sposv_(char *, jint *, jint *, jfloat *, jint *, jfloat *, jint *, int *);
+  
+  char uploChr = (char) uplo;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jfloat *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetFloatArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  sposv_(&uploChr, &n, &nrhs, aPtr, &lda, bPtr, &ldb, &info);
+  if(bPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, b, bPtrBase, 0);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_cgeev(JNIEnv *env, jclass this, jchar jobvl, jchar jobvr, jint n, jfloatArray a, jint aIdx, jint lda, jfloatArray w, jint wIdx, jfloatArray vl, jint vlIdx, jint ldvl, jfloatArray vr, jint vrIdx, jint ldvr, jfloatArray work, jint workIdx, jint lwork, jfloatArray rwork, jint rworkIdx)
+{
+  extern void cgeev_(char *, char *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, jfloat *, jint *, jfloat *, jint *, jfloat *, int *);
+  
+  char jobvlChr = (char) jobvl;
+  char jobvrChr = (char) jobvr;
+  jfloat *rworkPtrBase = 0, *rworkPtr = 0;
+  if (rwork) {
+    rworkPtrBase = (*env)->GetFloatArrayElements(env, rwork, NULL);
+    rworkPtr = rworkPtrBase + rworkIdx;
+  }
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, rwork) == JNI_TRUE)
+      aPtrBase = rworkPtrBase;
+    else
+      aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+  jfloat *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, rwork) == JNI_TRUE)
+      wPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetFloatArrayElements(env, w, NULL);
+    wPtr = wPtrBase + 2*wIdx;
+  }
+  jfloat *vlPtrBase = 0, *vlPtr = 0;
+  if (vl) {
+    if((*env)->IsSameObject(env, vl, rwork) == JNI_TRUE)
+      vlPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, vl, a) == JNI_TRUE)
+      vlPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vl, w) == JNI_TRUE)
+      vlPtrBase = wPtrBase;
+    else
+      vlPtrBase = (*env)->GetFloatArrayElements(env, vl, NULL);
+    vlPtr = vlPtrBase + 2*vlIdx;
+  }
+  jfloat *vrPtrBase = 0, *vrPtr = 0;
+  if (vr) {
+    if((*env)->IsSameObject(env, vr, rwork) == JNI_TRUE)
+      vrPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, a) == JNI_TRUE)
+      vrPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, w) == JNI_TRUE)
+      vrPtrBase = wPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, vl) == JNI_TRUE)
+      vrPtrBase = vlPtrBase;
+    else
+      vrPtrBase = (*env)->GetFloatArrayElements(env, vr, NULL);
+    vrPtr = vrPtrBase + 2*vrIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, rwork) == JNI_TRUE)
+      workPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vl) == JNI_TRUE)
+      workPtrBase = vlPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vr) == JNI_TRUE)
+      workPtrBase = vrPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + 2*workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  cgeev_(&jobvlChr, &jobvrChr, &n, aPtr, &lda, wPtr, vlPtr, &ldvl, vrPtr, &ldvr, workPtr, &lwork, rworkPtr, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    if (workPtrBase == vlPtrBase)
+      vlPtrBase = 0;
+    if (workPtrBase == vrPtrBase)
+      vrPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(vrPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, vr, vrPtrBase, 0);
+    if (vrPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (vrPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vrPtrBase == wPtrBase)
+      wPtrBase = 0;
+    if (vrPtrBase == vlPtrBase)
+      vlPtrBase = 0;
+    vrPtrBase = 0;
+  }
+  if(vlPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, vl, vlPtrBase, 0);
+    if (vlPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (vlPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vlPtrBase == wPtrBase)
+      wPtrBase = 0;
+    vlPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(rworkPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, rwork, rworkPtrBase, JNI_ABORT);
+    rworkPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dgeev(JNIEnv *env, jclass this, jchar jobvl, jchar jobvr, jint n, jdoubleArray a, jint aIdx, jint lda, jdoubleArray wr, jint wrIdx, jdoubleArray wi, jint wiIdx, jdoubleArray vl, jint vlIdx, jint ldvl, jdoubleArray vr, jint vrIdx, jint ldvr, jdoubleArray work, jint workIdx, jint lwork)
+{
+  extern void dgeev_(char *, char *, jint *, jdouble *, jint *, jdouble *, jdouble *, jdouble *, jint *, jdouble *, jint *, jdouble *, jint *, int *);
+  
+  char jobvlChr = (char) jobvl;
+  char jobvrChr = (char) jobvr;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jdouble *wrPtrBase = 0, *wrPtr = 0;
+  if (wr) {
+    if((*env)->IsSameObject(env, wr, a) == JNI_TRUE)
+      wrPtrBase = aPtrBase;
+    else
+      wrPtrBase = (*env)->GetDoubleArrayElements(env, wr, NULL);
+    wrPtr = wrPtrBase + wrIdx;
+  }
+  jdouble *wiPtrBase = 0, *wiPtr = 0;
+  if (wi) {
+    if((*env)->IsSameObject(env, wi, a) == JNI_TRUE)
+      wiPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, wi, wr) == JNI_TRUE)
+      wiPtrBase = wrPtrBase;
+    else
+      wiPtrBase = (*env)->GetDoubleArrayElements(env, wi, NULL);
+    wiPtr = wiPtrBase + wiIdx;
+  }
+  jdouble *vlPtrBase = 0, *vlPtr = 0;
+  if (vl) {
+    if((*env)->IsSameObject(env, vl, a) == JNI_TRUE)
+      vlPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vl, wr) == JNI_TRUE)
+      vlPtrBase = wrPtrBase;
+    else
+      if((*env)->IsSameObject(env, vl, wi) == JNI_TRUE)
+      vlPtrBase = wiPtrBase;
+    else
+      vlPtrBase = (*env)->GetDoubleArrayElements(env, vl, NULL);
+    vlPtr = vlPtrBase + vlIdx;
+  }
+  jdouble *vrPtrBase = 0, *vrPtr = 0;
+  if (vr) {
+    if((*env)->IsSameObject(env, vr, a) == JNI_TRUE)
+      vrPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, wr) == JNI_TRUE)
+      vrPtrBase = wrPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, wi) == JNI_TRUE)
+      vrPtrBase = wiPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, vl) == JNI_TRUE)
+      vrPtrBase = vlPtrBase;
+    else
+      vrPtrBase = (*env)->GetDoubleArrayElements(env, vr, NULL);
+    vrPtr = vrPtrBase + vrIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, wr) == JNI_TRUE)
+      workPtrBase = wrPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, wi) == JNI_TRUE)
+      workPtrBase = wiPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vl) == JNI_TRUE)
+      workPtrBase = vlPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vr) == JNI_TRUE)
+      workPtrBase = vrPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dgeev_(&jobvlChr, &jobvrChr, &n, aPtr, &lda, wrPtr, wiPtr, vlPtr, &ldvl, vrPtr, &ldvr, workPtr, &lwork, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wrPtrBase)
+      wrPtrBase = 0;
+    if (workPtrBase == wiPtrBase)
+      wiPtrBase = 0;
+    if (workPtrBase == vlPtrBase)
+      vlPtrBase = 0;
+    if (workPtrBase == vrPtrBase)
+      vrPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(vrPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, vr, vrPtrBase, 0);
+    if (vrPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vrPtrBase == wrPtrBase)
+      wrPtrBase = 0;
+    if (vrPtrBase == wiPtrBase)
+      wiPtrBase = 0;
+    if (vrPtrBase == vlPtrBase)
+      vlPtrBase = 0;
+    vrPtrBase = 0;
+  }
+  if(vlPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, vl, vlPtrBase, 0);
+    if (vlPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vlPtrBase == wrPtrBase)
+      wrPtrBase = 0;
+    if (vlPtrBase == wiPtrBase)
+      wiPtrBase = 0;
+    vlPtrBase = 0;
+  }
+  if(wiPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, wi, wiPtrBase, 0);
+    if (wiPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (wiPtrBase == wrPtrBase)
+      wrPtrBase = 0;
+    wiPtrBase = 0;
+  }
+  if(wrPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, wr, wrPtrBase, 0);
+    if (wrPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wrPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sgeev(JNIEnv *env, jclass this, jchar jobvl, jchar jobvr, jint n, jfloatArray a, jint aIdx, jint lda, jfloatArray wr, jint wrIdx, jfloatArray wi, jint wiIdx, jfloatArray vl, jint vlIdx, jint ldvl, jfloatArray vr, jint vrIdx, jint ldvr, jfloatArray work, jint workIdx, jint lwork)
+{
+  extern void sgeev_(char *, char *, jint *, jfloat *, jint *, jfloat *, jfloat *, jfloat *, jint *, jfloat *, jint *, jfloat *, jint *, int *);
+  
+  char jobvlChr = (char) jobvl;
+  char jobvrChr = (char) jobvr;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jfloat *wrPtrBase = 0, *wrPtr = 0;
+  if (wr) {
+    if((*env)->IsSameObject(env, wr, a) == JNI_TRUE)
+      wrPtrBase = aPtrBase;
+    else
+      wrPtrBase = (*env)->GetFloatArrayElements(env, wr, NULL);
+    wrPtr = wrPtrBase + wrIdx;
+  }
+  jfloat *wiPtrBase = 0, *wiPtr = 0;
+  if (wi) {
+    if((*env)->IsSameObject(env, wi, a) == JNI_TRUE)
+      wiPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, wi, wr) == JNI_TRUE)
+      wiPtrBase = wrPtrBase;
+    else
+      wiPtrBase = (*env)->GetFloatArrayElements(env, wi, NULL);
+    wiPtr = wiPtrBase + wiIdx;
+  }
+  jfloat *vlPtrBase = 0, *vlPtr = 0;
+  if (vl) {
+    if((*env)->IsSameObject(env, vl, a) == JNI_TRUE)
+      vlPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vl, wr) == JNI_TRUE)
+      vlPtrBase = wrPtrBase;
+    else
+      if((*env)->IsSameObject(env, vl, wi) == JNI_TRUE)
+      vlPtrBase = wiPtrBase;
+    else
+      vlPtrBase = (*env)->GetFloatArrayElements(env, vl, NULL);
+    vlPtr = vlPtrBase + vlIdx;
+  }
+  jfloat *vrPtrBase = 0, *vrPtr = 0;
+  if (vr) {
+    if((*env)->IsSameObject(env, vr, a) == JNI_TRUE)
+      vrPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, wr) == JNI_TRUE)
+      vrPtrBase = wrPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, wi) == JNI_TRUE)
+      vrPtrBase = wiPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, vl) == JNI_TRUE)
+      vrPtrBase = vlPtrBase;
+    else
+      vrPtrBase = (*env)->GetFloatArrayElements(env, vr, NULL);
+    vrPtr = vrPtrBase + vrIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, wr) == JNI_TRUE)
+      workPtrBase = wrPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, wi) == JNI_TRUE)
+      workPtrBase = wiPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vl) == JNI_TRUE)
+      workPtrBase = vlPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vr) == JNI_TRUE)
+      workPtrBase = vrPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  sgeev_(&jobvlChr, &jobvrChr, &n, aPtr, &lda, wrPtr, wiPtr, vlPtr, &ldvl, vrPtr, &ldvr, workPtr, &lwork, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wrPtrBase)
+      wrPtrBase = 0;
+    if (workPtrBase == wiPtrBase)
+      wiPtrBase = 0;
+    if (workPtrBase == vlPtrBase)
+      vlPtrBase = 0;
+    if (workPtrBase == vrPtrBase)
+      vrPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(vrPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, vr, vrPtrBase, 0);
+    if (vrPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vrPtrBase == wrPtrBase)
+      wrPtrBase = 0;
+    if (vrPtrBase == wiPtrBase)
+      wiPtrBase = 0;
+    if (vrPtrBase == vlPtrBase)
+      vlPtrBase = 0;
+    vrPtrBase = 0;
+  }
+  if(vlPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, vl, vlPtrBase, 0);
+    if (vlPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vlPtrBase == wrPtrBase)
+      wrPtrBase = 0;
+    if (vlPtrBase == wiPtrBase)
+      wiPtrBase = 0;
+    vlPtrBase = 0;
+  }
+  if(wiPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, wi, wiPtrBase, 0);
+    if (wiPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (wiPtrBase == wrPtrBase)
+      wrPtrBase = 0;
+    wiPtrBase = 0;
+  }
+  if(wrPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, wr, wrPtrBase, 0);
+    if (wrPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wrPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_zgeev(JNIEnv *env, jclass this, jchar jobvl, jchar jobvr, jint n, jdoubleArray a, jint aIdx, jint lda, jdoubleArray w, jint wIdx, jdoubleArray vl, jint vlIdx, jint ldvl, jdoubleArray vr, jint vrIdx, jint ldvr, jdoubleArray work, jint workIdx, jint lwork, jdoubleArray rwork, jint rworkIdx)
+{
+  extern void zgeev_(char *, char *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, jdouble *, jint *, jdouble *, jint *, jdouble *, int *);
+  
+  char jobvlChr = (char) jobvl;
+  char jobvrChr = (char) jobvr;
+  jdouble *rworkPtrBase = 0, *rworkPtr = 0;
+  if (rwork) {
+    rworkPtrBase = (*env)->GetDoubleArrayElements(env, rwork, NULL);
+    rworkPtr = rworkPtrBase + rworkIdx;
+  }
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, rwork) == JNI_TRUE)
+      aPtrBase = rworkPtrBase;
+    else
+      aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+  jdouble *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, rwork) == JNI_TRUE)
+      wPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      wPtrBase = (*env)->GetDoubleArrayElements(env, w, NULL);
+    wPtr = wPtrBase + 2*wIdx;
+  }
+  jdouble *vlPtrBase = 0, *vlPtr = 0;
+  if (vl) {
+    if((*env)->IsSameObject(env, vl, rwork) == JNI_TRUE)
+      vlPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, vl, a) == JNI_TRUE)
+      vlPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vl, w) == JNI_TRUE)
+      vlPtrBase = wPtrBase;
+    else
+      vlPtrBase = (*env)->GetDoubleArrayElements(env, vl, NULL);
+    vlPtr = vlPtrBase + 2*vlIdx;
+  }
+  jdouble *vrPtrBase = 0, *vrPtr = 0;
+  if (vr) {
+    if((*env)->IsSameObject(env, vr, rwork) == JNI_TRUE)
+      vrPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, a) == JNI_TRUE)
+      vrPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, w) == JNI_TRUE)
+      vrPtrBase = wPtrBase;
+    else
+      if((*env)->IsSameObject(env, vr, vl) == JNI_TRUE)
+      vrPtrBase = vlPtrBase;
+    else
+      vrPtrBase = (*env)->GetDoubleArrayElements(env, vr, NULL);
+    vrPtr = vrPtrBase + 2*vrIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, rwork) == JNI_TRUE)
+      workPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vl) == JNI_TRUE)
+      workPtrBase = vlPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vr) == JNI_TRUE)
+      workPtrBase = vrPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + 2*workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  zgeev_(&jobvlChr, &jobvrChr, &n, aPtr, &lda, wPtr, vlPtr, &ldvl, vrPtr, &ldvr, workPtr, &lwork, rworkPtr, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    if (workPtrBase == vlPtrBase)
+      vlPtrBase = 0;
+    if (workPtrBase == vrPtrBase)
+      vrPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(vrPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, vr, vrPtrBase, 0);
+    if (vrPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (vrPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vrPtrBase == wPtrBase)
+      wPtrBase = 0;
+    if (vrPtrBase == vlPtrBase)
+      vlPtrBase = 0;
+    vrPtrBase = 0;
+  }
+  if(vlPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, vl, vlPtrBase, 0);
+    if (vlPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (vlPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vlPtrBase == wPtrBase)
+      wPtrBase = 0;
+    vlPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(rworkPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, rwork, rworkPtrBase, JNI_ABORT);
+    rworkPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dgetrf(JNIEnv *env, jclass this, jint m, jint n, jdoubleArray a, jint aIdx, jint lda, jintArray ipiv, jint ipivIdx)
+{
+  extern void dgetrf_(jint *, jint *, jdouble *, jint *, jint *, int *);
+  
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *ipivPtrBase = 0, *ipivPtr = 0;
+  if (ipiv) {
+    ipivPtrBase = (*env)->GetIntArrayElements(env, ipiv, NULL);
+    ipivPtr = ipivPtrBase + ipivIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dgetrf_(&m, &n, aPtr, &lda, ipivPtr, &info);
+  if(ipivPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, ipiv, ipivPtrBase, 0);
+    ipivPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sgetrf(JNIEnv *env, jclass this, jint m, jint n, jfloatArray a, jint aIdx, jint lda, jintArray ipiv, jint ipivIdx)
+{
+  extern void sgetrf_(jint *, jint *, jfloat *, jint *, jint *, int *);
+  
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jint *ipivPtrBase = 0, *ipivPtr = 0;
+  if (ipiv) {
+    ipivPtrBase = (*env)->GetIntArrayElements(env, ipiv, NULL);
+    ipivPtr = ipivPtrBase + ipivIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  sgetrf_(&m, &n, aPtr, &lda, ipivPtr, &info);
+  if(ipivPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, ipiv, ipivPtrBase, 0);
+    ipivPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dpotrf(JNIEnv *env, jclass this, jchar uplo, jint n, jdoubleArray a, jint aIdx, jint lda)
+{
+  extern void dpotrf_(char *, jint *, jdouble *, jint *, int *);
+  
+  char uploChr = (char) uplo;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dpotrf_(&uploChr, &n, aPtr, &lda, &info);
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_spotrf(JNIEnv *env, jclass this, jchar uplo, jint n, jfloatArray a, jint aIdx, jint lda)
+{
+  extern void spotrf_(char *, jint *, jfloat *, jint *, int *);
+  
+  char uploChr = (char) uplo;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  spotrf_(&uploChr, &n, aPtr, &lda, &info);
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_cgesvd(JNIEnv *env, jclass this, jchar jobu, jchar jobvt, jint m, jint n, jfloatArray a, jint aIdx, jint lda, jfloatArray s, jint sIdx, jfloatArray u, jint uIdx, jint ldu, jfloatArray vt, jint vtIdx, jint ldvt, jfloatArray work, jint workIdx, jint lwork, jfloatArray rwork, jint rworkIdx)
+{
+  extern void cgesvd_(char *, char *, jint *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, jfloat *, jint *, jfloat *, jint *, jfloat *, int *);
+  
+  char jobuChr = (char) jobu;
+  char jobvtChr = (char) jobvt;
+  jfloat *rworkPtrBase = 0, *rworkPtr = 0;
+  if (rwork) {
+    rworkPtrBase = (*env)->GetFloatArrayElements(env, rwork, NULL);
+    rworkPtr = rworkPtrBase + rworkIdx;
+  }
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, rwork) == JNI_TRUE)
+      aPtrBase = rworkPtrBase;
+    else
+      aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+  jfloat *sPtrBase = 0, *sPtr = 0;
+  if (s) {
+    if((*env)->IsSameObject(env, s, rwork) == JNI_TRUE)
+      sPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, s, a) == JNI_TRUE)
+      sPtrBase = aPtrBase;
+    else
+      sPtrBase = (*env)->GetFloatArrayElements(env, s, NULL);
+    sPtr = sPtrBase + sIdx;
+  }
+  jfloat *uPtrBase = 0, *uPtr = 0;
+  if (u) {
+    if((*env)->IsSameObject(env, u, rwork) == JNI_TRUE)
+      uPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, u, a) == JNI_TRUE)
+      uPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, u, s) == JNI_TRUE)
+      uPtrBase = sPtrBase;
+    else
+      uPtrBase = (*env)->GetFloatArrayElements(env, u, NULL);
+    uPtr = uPtrBase + 2*uIdx;
+  }
+  jfloat *vtPtrBase = 0, *vtPtr = 0;
+  if (vt) {
+    if((*env)->IsSameObject(env, vt, rwork) == JNI_TRUE)
+      vtPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, a) == JNI_TRUE)
+      vtPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, s) == JNI_TRUE)
+      vtPtrBase = sPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, u) == JNI_TRUE)
+      vtPtrBase = uPtrBase;
+    else
+      vtPtrBase = (*env)->GetFloatArrayElements(env, vt, NULL);
+    vtPtr = vtPtrBase + 2*vtIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, rwork) == JNI_TRUE)
+      workPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, s) == JNI_TRUE)
+      workPtrBase = sPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, u) == JNI_TRUE)
+      workPtrBase = uPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vt) == JNI_TRUE)
+      workPtrBase = vtPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + 2*workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  cgesvd_(&jobuChr, &jobvtChr, &m, &n, aPtr, &lda, sPtr, uPtr, &ldu, vtPtr, &ldvt, workPtr, &lwork, rworkPtr, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == sPtrBase)
+      sPtrBase = 0;
+    if (workPtrBase == uPtrBase)
+      uPtrBase = 0;
+    if (workPtrBase == vtPtrBase)
+      vtPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(vtPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, vt, vtPtrBase, 0);
+    if (vtPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (vtPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vtPtrBase == sPtrBase)
+      sPtrBase = 0;
+    if (vtPtrBase == uPtrBase)
+      uPtrBase = 0;
+    vtPtrBase = 0;
+  }
+  if(uPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, u, uPtrBase, 0);
+    if (uPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (uPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (uPtrBase == sPtrBase)
+      sPtrBase = 0;
+    uPtrBase = 0;
+  }
+  if(sPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, s, sPtrBase, 0);
+    if (sPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (sPtrBase == aPtrBase)
+      aPtrBase = 0;
+    sPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(rworkPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, rwork, rworkPtrBase, JNI_ABORT);
+    rworkPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dgesvd(JNIEnv *env, jclass this, jchar jobu, jchar jobvt, jint m, jint n, jdoubleArray a, jint aIdx, jint lda, jdoubleArray s, jint sIdx, jdoubleArray u, jint uIdx, jint ldu, jdoubleArray vt, jint vtIdx, jint ldvt, jdoubleArray work, jint workIdx, jint lwork)
+{
+  extern void dgesvd_(char *, char *, jint *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, jdouble *, jint *, jdouble *, jint *, int *);
+  
+  char jobuChr = (char) jobu;
+  char jobvtChr = (char) jobvt;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jdouble *sPtrBase = 0, *sPtr = 0;
+  if (s) {
+    if((*env)->IsSameObject(env, s, a) == JNI_TRUE)
+      sPtrBase = aPtrBase;
+    else
+      sPtrBase = (*env)->GetDoubleArrayElements(env, s, NULL);
+    sPtr = sPtrBase + sIdx;
+  }
+  jdouble *uPtrBase = 0, *uPtr = 0;
+  if (u) {
+    if((*env)->IsSameObject(env, u, a) == JNI_TRUE)
+      uPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, u, s) == JNI_TRUE)
+      uPtrBase = sPtrBase;
+    else
+      uPtrBase = (*env)->GetDoubleArrayElements(env, u, NULL);
+    uPtr = uPtrBase + uIdx;
+  }
+  jdouble *vtPtrBase = 0, *vtPtr = 0;
+  if (vt) {
+    if((*env)->IsSameObject(env, vt, a) == JNI_TRUE)
+      vtPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, s) == JNI_TRUE)
+      vtPtrBase = sPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, u) == JNI_TRUE)
+      vtPtrBase = uPtrBase;
+    else
+      vtPtrBase = (*env)->GetDoubleArrayElements(env, vt, NULL);
+    vtPtr = vtPtrBase + vtIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, s) == JNI_TRUE)
+      workPtrBase = sPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, u) == JNI_TRUE)
+      workPtrBase = uPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vt) == JNI_TRUE)
+      workPtrBase = vtPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dgesvd_(&jobuChr, &jobvtChr, &m, &n, aPtr, &lda, sPtr, uPtr, &ldu, vtPtr, &ldvt, workPtr, &lwork, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == sPtrBase)
+      sPtrBase = 0;
+    if (workPtrBase == uPtrBase)
+      uPtrBase = 0;
+    if (workPtrBase == vtPtrBase)
+      vtPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(vtPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, vt, vtPtrBase, 0);
+    if (vtPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vtPtrBase == sPtrBase)
+      sPtrBase = 0;
+    if (vtPtrBase == uPtrBase)
+      uPtrBase = 0;
+    vtPtrBase = 0;
+  }
+  if(uPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, u, uPtrBase, 0);
+    if (uPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (uPtrBase == sPtrBase)
+      sPtrBase = 0;
+    uPtrBase = 0;
+  }
+  if(sPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, s, sPtrBase, 0);
+    if (sPtrBase == aPtrBase)
+      aPtrBase = 0;
+    sPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sgesvd(JNIEnv *env, jclass this, jchar jobu, jchar jobvt, jint m, jint n, jfloatArray a, jint aIdx, jint lda, jfloatArray s, jint sIdx, jfloatArray u, jint uIdx, jint ldu, jfloatArray vt, jint vtIdx, jint ldvt, jfloatArray work, jint workIdx, jint lwork)
+{
+  extern void sgesvd_(char *, char *, jint *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, jfloat *, jint *, jfloat *, jint *, int *);
+  
+  char jobuChr = (char) jobu;
+  char jobvtChr = (char) jobvt;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jfloat *sPtrBase = 0, *sPtr = 0;
+  if (s) {
+    if((*env)->IsSameObject(env, s, a) == JNI_TRUE)
+      sPtrBase = aPtrBase;
+    else
+      sPtrBase = (*env)->GetFloatArrayElements(env, s, NULL);
+    sPtr = sPtrBase + sIdx;
+  }
+  jfloat *uPtrBase = 0, *uPtr = 0;
+  if (u) {
+    if((*env)->IsSameObject(env, u, a) == JNI_TRUE)
+      uPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, u, s) == JNI_TRUE)
+      uPtrBase = sPtrBase;
+    else
+      uPtrBase = (*env)->GetFloatArrayElements(env, u, NULL);
+    uPtr = uPtrBase + uIdx;
+  }
+  jfloat *vtPtrBase = 0, *vtPtr = 0;
+  if (vt) {
+    if((*env)->IsSameObject(env, vt, a) == JNI_TRUE)
+      vtPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, s) == JNI_TRUE)
+      vtPtrBase = sPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, u) == JNI_TRUE)
+      vtPtrBase = uPtrBase;
+    else
+      vtPtrBase = (*env)->GetFloatArrayElements(env, vt, NULL);
+    vtPtr = vtPtrBase + vtIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, s) == JNI_TRUE)
+      workPtrBase = sPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, u) == JNI_TRUE)
+      workPtrBase = uPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vt) == JNI_TRUE)
+      workPtrBase = vtPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  sgesvd_(&jobuChr, &jobvtChr, &m, &n, aPtr, &lda, sPtr, uPtr, &ldu, vtPtr, &ldvt, workPtr, &lwork, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == sPtrBase)
+      sPtrBase = 0;
+    if (workPtrBase == uPtrBase)
+      uPtrBase = 0;
+    if (workPtrBase == vtPtrBase)
+      vtPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(vtPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, vt, vtPtrBase, 0);
+    if (vtPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vtPtrBase == sPtrBase)
+      sPtrBase = 0;
+    if (vtPtrBase == uPtrBase)
+      uPtrBase = 0;
+    vtPtrBase = 0;
+  }
+  if(uPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, u, uPtrBase, 0);
+    if (uPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (uPtrBase == sPtrBase)
+      sPtrBase = 0;
+    uPtrBase = 0;
+  }
+  if(sPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, s, sPtrBase, 0);
+    if (sPtrBase == aPtrBase)
+      aPtrBase = 0;
+    sPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_zgesvd(JNIEnv *env, jclass this, jchar jobu, jchar jobvt, jint m, jint n, jdoubleArray a, jint aIdx, jint lda, jdoubleArray s, jint sIdx, jdoubleArray u, jint uIdx, jint ldu, jdoubleArray vt, jint vtIdx, jint ldvt, jdoubleArray work, jint workIdx, jint lwork, jdoubleArray rwork, jint rworkIdx)
+{
+  extern void zgesvd_(char *, char *, jint *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, jdouble *, jint *, jdouble *, jint *, jdouble *, int *);
+  
+  char jobuChr = (char) jobu;
+  char jobvtChr = (char) jobvt;
+  jdouble *rworkPtrBase = 0, *rworkPtr = 0;
+  if (rwork) {
+    rworkPtrBase = (*env)->GetDoubleArrayElements(env, rwork, NULL);
+    rworkPtr = rworkPtrBase + rworkIdx;
+  }
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    if((*env)->IsSameObject(env, a, rwork) == JNI_TRUE)
+      aPtrBase = rworkPtrBase;
+    else
+      aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + 2*aIdx;
+  }
+  jdouble *sPtrBase = 0, *sPtr = 0;
+  if (s) {
+    if((*env)->IsSameObject(env, s, rwork) == JNI_TRUE)
+      sPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, s, a) == JNI_TRUE)
+      sPtrBase = aPtrBase;
+    else
+      sPtrBase = (*env)->GetDoubleArrayElements(env, s, NULL);
+    sPtr = sPtrBase + sIdx;
+  }
+  jdouble *uPtrBase = 0, *uPtr = 0;
+  if (u) {
+    if((*env)->IsSameObject(env, u, rwork) == JNI_TRUE)
+      uPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, u, a) == JNI_TRUE)
+      uPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, u, s) == JNI_TRUE)
+      uPtrBase = sPtrBase;
+    else
+      uPtrBase = (*env)->GetDoubleArrayElements(env, u, NULL);
+    uPtr = uPtrBase + 2*uIdx;
+  }
+  jdouble *vtPtrBase = 0, *vtPtr = 0;
+  if (vt) {
+    if((*env)->IsSameObject(env, vt, rwork) == JNI_TRUE)
+      vtPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, a) == JNI_TRUE)
+      vtPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, s) == JNI_TRUE)
+      vtPtrBase = sPtrBase;
+    else
+      if((*env)->IsSameObject(env, vt, u) == JNI_TRUE)
+      vtPtrBase = uPtrBase;
+    else
+      vtPtrBase = (*env)->GetDoubleArrayElements(env, vt, NULL);
+    vtPtr = vtPtrBase + 2*vtIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, rwork) == JNI_TRUE)
+      workPtrBase = rworkPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, s) == JNI_TRUE)
+      workPtrBase = sPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, u) == JNI_TRUE)
+      workPtrBase = uPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, vt) == JNI_TRUE)
+      workPtrBase = vtPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + 2*workIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  zgesvd_(&jobuChr, &jobvtChr, &m, &n, aPtr, &lda, sPtr, uPtr, &ldu, vtPtr, &ldvt, workPtr, &lwork, rworkPtr, &info);
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == sPtrBase)
+      sPtrBase = 0;
+    if (workPtrBase == uPtrBase)
+      uPtrBase = 0;
+    if (workPtrBase == vtPtrBase)
+      vtPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(vtPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, vt, vtPtrBase, 0);
+    if (vtPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (vtPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (vtPtrBase == sPtrBase)
+      sPtrBase = 0;
+    if (vtPtrBase == uPtrBase)
+      uPtrBase = 0;
+    vtPtrBase = 0;
+  }
+  if(uPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, u, uPtrBase, 0);
+    if (uPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (uPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (uPtrBase == sPtrBase)
+      sPtrBase = 0;
+    uPtrBase = 0;
+  }
+  if(sPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, s, sPtrBase, 0);
+    if (sPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    if (sPtrBase == aPtrBase)
+      aPtrBase = 0;
+    sPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    if (aPtrBase == rworkPtrBase)
+      rworkPtrBase = 0;
+    aPtrBase = 0;
+  }
+  if(rworkPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, rwork, rworkPtrBase, JNI_ABORT);
+    rworkPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsygvd(JNIEnv *env, jclass this, jint itype, jchar jobz, jchar uplo, jint n, jdoubleArray a, jint aIdx, jint lda, jdoubleArray b, jint bIdx, jint ldb, jdoubleArray w, jint wIdx, jdoubleArray work, jint workIdx, jint lwork, jintArray iwork, jint iworkIdx, jint liwork)
+{
+  extern void dsygvd_(jint *, char *, char *, jint *, jdouble *, jint *, jdouble *, jint *, jdouble *, jdouble *, jint *, jint *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char uploChr = (char) uplo;
+  jdouble *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetDoubleArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jdouble *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetDoubleArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  jdouble *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, w, b) == JNI_TRUE)
+      wPtrBase = bPtrBase;
+    else
+      wPtrBase = (*env)->GetDoubleArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jdouble *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, b) == JNI_TRUE)
+      workPtrBase = bPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      workPtrBase = (*env)->GetDoubleArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  jint *iworkPtrBase = 0, *iworkPtr = 0;
+  if (iwork) {
+    iworkPtrBase = (*env)->GetIntArrayElements(env, iwork, NULL);
+    iworkPtr = iworkPtrBase + iworkIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  dsygvd_(&itype, &jobzChr, &uploChr, &n, aPtr, &lda, bPtr, &ldb, wPtr, workPtr, &lwork, iworkPtr, &liwork, &info);
+  if(iworkPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, iwork, iworkPtrBase, 0);
+    iworkPtrBase = 0;
+  }
+  if(workPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == bPtrBase)
+      bPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (wPtrBase == bPtrBase)
+      bPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(bPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, b, bPtrBase, 0);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseDoubleArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssygvd(JNIEnv *env, jclass this, jint itype, jchar jobz, jchar uplo, jint n, jfloatArray a, jint aIdx, jint lda, jfloatArray b, jint bIdx, jint ldb, jfloatArray w, jint wIdx, jfloatArray work, jint workIdx, jint lwork, jintArray iwork, jint iworkIdx, jint liwork)
+{
+  extern void ssygvd_(jint *, char *, char *, jint *, jfloat *, jint *, jfloat *, jint *, jfloat *, jfloat *, jint *, jint *, jint *, int *);
+  
+  char jobzChr = (char) jobz;
+  char uploChr = (char) uplo;
+  jfloat *aPtrBase = 0, *aPtr = 0;
+  if (a) {
+    aPtrBase = (*env)->GetFloatArrayElements(env, a, NULL);
+    aPtr = aPtrBase + aIdx;
+  }
+  jfloat *bPtrBase = 0, *bPtr = 0;
+  if (b) {
+    if((*env)->IsSameObject(env, b, a) == JNI_TRUE)
+      bPtrBase = aPtrBase;
+    else
+      bPtrBase = (*env)->GetFloatArrayElements(env, b, NULL);
+    bPtr = bPtrBase + bIdx;
+  }
+  jfloat *wPtrBase = 0, *wPtr = 0;
+  if (w) {
+    if((*env)->IsSameObject(env, w, a) == JNI_TRUE)
+      wPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, w, b) == JNI_TRUE)
+      wPtrBase = bPtrBase;
+    else
+      wPtrBase = (*env)->GetFloatArrayElements(env, w, NULL);
+    wPtr = wPtrBase + wIdx;
+  }
+  jfloat *workPtrBase = 0, *workPtr = 0;
+  if (work) {
+    if((*env)->IsSameObject(env, work, a) == JNI_TRUE)
+      workPtrBase = aPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, b) == JNI_TRUE)
+      workPtrBase = bPtrBase;
+    else
+      if((*env)->IsSameObject(env, work, w) == JNI_TRUE)
+      workPtrBase = wPtrBase;
+    else
+      workPtrBase = (*env)->GetFloatArrayElements(env, work, NULL);
+    workPtr = workPtrBase + workIdx;
+  }
+  jint *iworkPtrBase = 0, *iworkPtr = 0;
+  if (iwork) {
+    iworkPtrBase = (*env)->GetIntArrayElements(env, iwork, NULL);
+    iworkPtr = iworkPtrBase + iworkIdx;
+  }
+  int info;
+
+  savedEnv = env;
+  ssygvd_(&itype, &jobzChr, &uploChr, &n, aPtr, &lda, bPtr, &ldb, wPtr, workPtr, &lwork, iworkPtr, &liwork, &info);
+  if(iworkPtrBase) {
+    (*env)->ReleaseIntArrayElements(env, iwork, iworkPtrBase, 0);
+    iworkPtrBase = 0;
+  }
+  if(workPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, work, workPtrBase, 0);
+    if (workPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (workPtrBase == bPtrBase)
+      bPtrBase = 0;
+    if (workPtrBase == wPtrBase)
+      wPtrBase = 0;
+    workPtrBase = 0;
+  }
+  if(wPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, w, wPtrBase, 0);
+    if (wPtrBase == aPtrBase)
+      aPtrBase = 0;
+    if (wPtrBase == bPtrBase)
+      bPtrBase = 0;
+    wPtrBase = 0;
+  }
+  if(bPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, b, bPtrBase, 0);
+    if (bPtrBase == aPtrBase)
+      aPtrBase = 0;
+    bPtrBase = 0;
+  }
+  if(aPtrBase) {
+    (*env)->ReleaseFloatArrayElements(env, a, aPtrBase, 0);
+    aPtrBase = 0;
+  }
+
+  return info;
+}
+
diff --git a/native/jblas_arch_flavor.c b/src/main/c/jblas_arch_flavor.c
similarity index 100%
rename from native/jblas_arch_flavor.c
rename to src/main/c/jblas_arch_flavor.c
diff --git a/src/main/c/org_jblas_NativeBlas.h b/src/main/c/org_jblas_NativeBlas.h
new file mode 100644
index 0000000..011a474
--- /dev/null
+++ b/src/main/c/org_jblas_NativeBlas.h
@@ -0,0 +1,640 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_jblas_NativeBlas */
+
+#ifndef _Included_org_jblas_NativeBlas
+#define _Included_org_jblas_NativeBlas
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* Inaccessible static: intDummy */
+/* Inaccessible static: doubleDummy */
+/* Inaccessible static: floatDummy */
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    ccopy
+ * Signature: (I[FII[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_ccopy
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dcopy
+ * Signature: (I[DII[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dcopy
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    scopy
+ * Signature: (I[FII[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_scopy
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zcopy
+ * Signature: (I[DII[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zcopy
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cswap
+ * Signature: (I[FII[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cswap
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dswap
+ * Signature: (I[DII[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dswap
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sswap
+ * Signature: (I[FII[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sswap
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zswap
+ * Signature: (I[DII[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zswap
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    caxpy
+ * Signature: (ILorg/jblas/ComplexFloat;[FII[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_caxpy
+  (JNIEnv *, jclass, jint, jobject, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    daxpy
+ * Signature: (ID[DII[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_daxpy
+  (JNIEnv *, jclass, jint, jdouble, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    saxpy
+ * Signature: (IF[FII[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_saxpy
+  (JNIEnv *, jclass, jint, jfloat, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zaxpy
+ * Signature: (ILorg/jblas/ComplexDouble;[DII[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zaxpy
+  (JNIEnv *, jclass, jint, jobject, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cscal
+ * Signature: (ILorg/jblas/ComplexFloat;[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cscal
+  (JNIEnv *, jclass, jint, jobject, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dscal
+ * Signature: (ID[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dscal
+  (JNIEnv *, jclass, jint, jdouble, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sscal
+ * Signature: (IF[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sscal
+  (JNIEnv *, jclass, jint, jfloat, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zscal
+ * Signature: (ILorg/jblas/ComplexDouble;[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zscal
+  (JNIEnv *, jclass, jint, jobject, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    csscal
+ * Signature: (IF[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_csscal
+  (JNIEnv *, jclass, jint, jfloat, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zdscal
+ * Signature: (ID[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zdscal
+  (JNIEnv *, jclass, jint, jdouble, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cdotc
+ * Signature: (I[FII[FII)Lorg/jblas/ComplexFloat;
+ */
+JNIEXPORT jobject JNICALL Java_org_jblas_NativeBlas_cdotc
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cdotu
+ * Signature: (I[FII[FII)Lorg/jblas/ComplexFloat;
+ */
+JNIEXPORT jobject JNICALL Java_org_jblas_NativeBlas_cdotu
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    ddot
+ * Signature: (I[DII[DII)D
+ */
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_ddot
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sdot
+ * Signature: (I[FII[FII)F
+ */
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_sdot
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zdotc
+ * Signature: (I[DII[DII)Lorg/jblas/ComplexDouble;
+ */
+JNIEXPORT jobject JNICALL Java_org_jblas_NativeBlas_zdotc
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zdotu
+ * Signature: (I[DII[DII)Lorg/jblas/ComplexDouble;
+ */
+JNIEXPORT jobject JNICALL Java_org_jblas_NativeBlas_zdotu
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dnrm2
+ * Signature: (I[DII)D
+ */
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_dnrm2
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dznrm2
+ * Signature: (I[DII)D
+ */
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_dznrm2
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    scnrm2
+ * Signature: (I[FII)F
+ */
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_scnrm2
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    snrm2
+ * Signature: (I[FII)F
+ */
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_snrm2
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dasum
+ * Signature: (I[DII)D
+ */
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_dasum
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dzasum
+ * Signature: (I[DII)D
+ */
+JNIEXPORT jdouble JNICALL Java_org_jblas_NativeBlas_dzasum
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sasum
+ * Signature: (I[FII)F
+ */
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_sasum
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    scasum
+ * Signature: (I[FII)F
+ */
+JNIEXPORT jfloat JNICALL Java_org_jblas_NativeBlas_scasum
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    icamax
+ * Signature: (I[FII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_icamax
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    idamax
+ * Signature: (I[DII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_idamax
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    isamax
+ * Signature: (I[FII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_isamax
+  (JNIEnv *, jclass, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    izamax
+ * Signature: (I[DII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_izamax
+  (JNIEnv *, jclass, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cgemv
+ * Signature: (CIILorg/jblas/ComplexFloat;[FII[FIILorg/jblas/ComplexFloat;[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cgemv
+  (JNIEnv *, jclass, jchar, jint, jint, jobject, jfloatArray, jint, jint, jfloatArray, jint, jint, jobject, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dgemv
+ * Signature: (CIID[DII[DIID[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dgemv
+  (JNIEnv *, jclass, jchar, jint, jint, jdouble, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdouble, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sgemv
+ * Signature: (CIIF[FII[FIIF[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sgemv
+  (JNIEnv *, jclass, jchar, jint, jint, jfloat, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloat, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zgemv
+ * Signature: (CIILorg/jblas/ComplexDouble;[DII[DIILorg/jblas/ComplexDouble;[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zgemv
+  (JNIEnv *, jclass, jchar, jint, jint, jobject, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jobject, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cgerc
+ * Signature: (IILorg/jblas/ComplexFloat;[FII[FII[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cgerc
+  (JNIEnv *, jclass, jint, jint, jobject, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cgeru
+ * Signature: (IILorg/jblas/ComplexFloat;[FII[FII[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cgeru
+  (JNIEnv *, jclass, jint, jint, jobject, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dger
+ * Signature: (IID[DII[DII[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dger
+  (JNIEnv *, jclass, jint, jint, jdouble, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sger
+ * Signature: (IIF[FII[FII[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sger
+  (JNIEnv *, jclass, jint, jint, jfloat, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zgerc
+ * Signature: (IILorg/jblas/ComplexDouble;[DII[DII[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zgerc
+  (JNIEnv *, jclass, jint, jint, jobject, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zgeru
+ * Signature: (IILorg/jblas/ComplexDouble;[DII[DII[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zgeru
+  (JNIEnv *, jclass, jint, jint, jobject, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cgemm
+ * Signature: (CCIIILorg/jblas/ComplexFloat;[FII[FIILorg/jblas/ComplexFloat;[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_cgemm
+  (JNIEnv *, jclass, jchar, jchar, jint, jint, jint, jobject, jfloatArray, jint, jint, jfloatArray, jint, jint, jobject, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dgemm
+ * Signature: (CCIIID[DII[DIID[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_dgemm
+  (JNIEnv *, jclass, jchar, jchar, jint, jint, jint, jdouble, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdouble, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sgemm
+ * Signature: (CCIIIF[FII[FIIF[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_sgemm
+  (JNIEnv *, jclass, jchar, jchar, jint, jint, jint, jfloat, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloat, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zgemm
+ * Signature: (CCIIILorg/jblas/ComplexDouble;[DII[DIILorg/jblas/ComplexDouble;[DII)V
+ */
+JNIEXPORT void JNICALL Java_org_jblas_NativeBlas_zgemm
+  (JNIEnv *, jclass, jchar, jchar, jint, jint, jint, jobject, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jobject, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dgesv
+ * Signature: (II[DII[II[DII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dgesv
+  (JNIEnv *, jclass, jint, jint, jdoubleArray, jint, jint, jintArray, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sgesv
+ * Signature: (II[FII[II[FII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sgesv
+  (JNIEnv *, jclass, jint, jint, jfloatArray, jint, jint, jintArray, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dsysv
+ * Signature: (CII[DII[II[DII[DII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsysv
+  (JNIEnv *, jclass, jchar, jint, jint, jdoubleArray, jint, jint, jintArray, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    ssysv
+ * Signature: (CII[FII[II[FII[FII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssysv
+  (JNIEnv *, jclass, jchar, jint, jint, jfloatArray, jint, jint, jintArray, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dsyev
+ * Signature: (CCI[DII[DI[DII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsyev
+  (JNIEnv *, jclass, jchar, jchar, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    ssyev
+ * Signature: (CCI[FII[FI[FII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssyev
+  (JNIEnv *, jclass, jchar, jchar, jint, jfloatArray, jint, jint, jfloatArray, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dsyevd
+ * Signature: (CCI[DII[DI[DII[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsyevd
+  (JNIEnv *, jclass, jchar, jchar, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jdoubleArray, jint, jint, jintArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dsyevr
+ * Signature: (CCCI[DIIDDIID[II[DI[DII[II[DII[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsyevr
+  (JNIEnv *, jclass, jchar, jchar, jchar, jint, jdoubleArray, jint, jint, jdouble, jdouble, jint, jint, jdouble, jintArray, jint, jdoubleArray, jint, jdoubleArray, jint, jint, jintArray, jint, jdoubleArray, jint, jint, jintArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dsyevx
+ * Signature: (CCCI[DIIDDIID[II[DI[DII[DII[II[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsyevx
+  (JNIEnv *, jclass, jchar, jchar, jchar, jint, jdoubleArray, jint, jint, jdouble, jdouble, jint, jint, jdouble, jintArray, jint, jdoubleArray, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jintArray, jint, jintArray, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    ssyevd
+ * Signature: (CCI[FII[FI[FII[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssyevd
+  (JNIEnv *, jclass, jchar, jchar, jint, jfloatArray, jint, jint, jfloatArray, jint, jfloatArray, jint, jint, jintArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    ssyevr
+ * Signature: (CCCI[FIIFFIIF[II[FI[FII[II[FII[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssyevr
+  (JNIEnv *, jclass, jchar, jchar, jchar, jint, jfloatArray, jint, jint, jfloat, jfloat, jint, jint, jfloat, jintArray, jint, jfloatArray, jint, jfloatArray, jint, jint, jintArray, jint, jfloatArray, jint, jint, jintArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    ssyevx
+ * Signature: (CCCI[FIIFFIIF[II[FI[FII[FII[II[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssyevx
+  (JNIEnv *, jclass, jchar, jchar, jchar, jint, jfloatArray, jint, jint, jfloat, jfloat, jint, jint, jfloat, jintArray, jint, jfloatArray, jint, jfloatArray, jint, jint, jfloatArray, jint, jint, jintArray, jint, jintArray, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dposv
+ * Signature: (CII[DII[DII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dposv
+  (JNIEnv *, jclass, jchar, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sposv
+ * Signature: (CII[FII[FII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sposv
+  (JNIEnv *, jclass, jchar, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cgeev
+ * Signature: (CCI[FII[FI[FII[FII[FII[FI)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_cgeev
+  (JNIEnv *, jclass, jchar, jchar, jint, jfloatArray, jint, jint, jfloatArray, jint, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dgeev
+ * Signature: (CCI[DII[DI[DI[DII[DII[DII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dgeev
+  (JNIEnv *, jclass, jchar, jchar, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jdoubleArray, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sgeev
+ * Signature: (CCI[FII[FI[FI[FII[FII[FII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sgeev
+  (JNIEnv *, jclass, jchar, jchar, jint, jfloatArray, jint, jint, jfloatArray, jint, jfloatArray, jint, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zgeev
+ * Signature: (CCI[DII[DI[DII[DII[DII[DI)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_zgeev
+  (JNIEnv *, jclass, jchar, jchar, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dgetrf
+ * Signature: (II[DII[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dgetrf
+  (JNIEnv *, jclass, jint, jint, jdoubleArray, jint, jint, jintArray, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sgetrf
+ * Signature: (II[FII[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sgetrf
+  (JNIEnv *, jclass, jint, jint, jfloatArray, jint, jint, jintArray, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dpotrf
+ * Signature: (CI[DII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dpotrf
+  (JNIEnv *, jclass, jchar, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    spotrf
+ * Signature: (CI[FII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_spotrf
+  (JNIEnv *, jclass, jchar, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    cgesvd
+ * Signature: (CCII[FII[FI[FII[FII[FII[FI)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_cgesvd
+  (JNIEnv *, jclass, jchar, jchar, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dgesvd
+ * Signature: (CCII[DII[DI[DII[DII[DII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dgesvd
+  (JNIEnv *, jclass, jchar, jchar, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    sgesvd
+ * Signature: (CCII[FII[FI[FII[FII[FII)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_sgesvd
+  (JNIEnv *, jclass, jchar, jchar, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    zgesvd
+ * Signature: (CCII[DII[DI[DII[DII[DII[DI)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_zgesvd
+  (JNIEnv *, jclass, jchar, jchar, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    dsygvd
+ * Signature: (ICCI[DII[DII[DI[DII[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_dsygvd
+  (JNIEnv *, jclass, jint, jchar, jchar, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jint, jdoubleArray, jint, jdoubleArray, jint, jint, jintArray, jint, jint);
+
+/*
+ * Class:     org_jblas_NativeBlas
+ * Method:    ssygvd
+ * Signature: (ICCI[FII[FII[FI[FII[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_NativeBlas_ssygvd
+  (JNIEnv *, jclass, jint, jchar, jchar, jint, jfloatArray, jint, jint, jfloatArray, jint, jint, jfloatArray, jint, jfloatArray, jint, jint, jintArray, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/main/c/org_jblas_util_ArchFlavor.h b/src/main/c/org_jblas_util_ArchFlavor.h
new file mode 100644
index 0000000..3b223b7
--- /dev/null
+++ b/src/main/c/org_jblas_util_ArchFlavor.h
@@ -0,0 +1,30 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_jblas_util_ArchFlavor */
+
+#ifndef _Included_org_jblas_util_ArchFlavor
+#define _Included_org_jblas_util_ArchFlavor
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* Inaccessible static: fixedFlavor */
+#undef org_jblas_util_ArchFlavor_SSE
+#define org_jblas_util_ArchFlavor_SSE 1L
+#undef org_jblas_util_ArchFlavor_SSE2
+#define org_jblas_util_ArchFlavor_SSE2 2L
+#undef org_jblas_util_ArchFlavor_SSE3
+#define org_jblas_util_ArchFlavor_SSE3 3L
+#undef org_jblas_util_ArchFlavor_NO_SSE
+#define org_jblas_util_ArchFlavor_NO_SSE -1L
+/*
+ * Class:     org_jblas_util_ArchFlavor
+ * Method:    SSELevel
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_jblas_util_ArchFlavor_SSELevel
+  (JNIEnv *, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/org/jblas/ComplexDouble.java b/src/main/java/org/jblas/ComplexDouble.java
similarity index 100%
rename from src/org/jblas/ComplexDouble.java
rename to src/main/java/org/jblas/ComplexDouble.java
diff --git a/src/org/jblas/ComplexDoubleMatrix.java b/src/main/java/org/jblas/ComplexDoubleMatrix.java
similarity index 99%
rename from src/org/jblas/ComplexDoubleMatrix.java
rename to src/main/java/org/jblas/ComplexDoubleMatrix.java
index 433e2d8..1f8b345 100644
--- a/src/org/jblas/ComplexDoubleMatrix.java
+++ b/src/main/java/org/jblas/ComplexDoubleMatrix.java
@@ -768,7 +768,7 @@ public class ComplexDoubleMatrix {
 
         /** Get matrix element, passing the variable to store the result. */
         public ComplexDouble get(int rowIndex, int columnIndex, ComplexDouble result) {
-            return get(index(rowIndex, columnIndex));
+            return get(index(rowIndex, columnIndex), result);
         }
 	
 	public DoubleMatrix getReal() {
diff --git a/src/org/jblas/ComplexFloat.java b/src/main/java/org/jblas/ComplexFloat.java
similarity index 100%
rename from src/org/jblas/ComplexFloat.java
rename to src/main/java/org/jblas/ComplexFloat.java
diff --git a/src/org/jblas/ComplexFloatMatrix.java b/src/main/java/org/jblas/ComplexFloatMatrix.java
similarity index 99%
rename from src/org/jblas/ComplexFloatMatrix.java
rename to src/main/java/org/jblas/ComplexFloatMatrix.java
index 271a2b7..2b11fed 100644
--- a/src/org/jblas/ComplexFloatMatrix.java
+++ b/src/main/java/org/jblas/ComplexFloatMatrix.java
@@ -768,7 +768,7 @@ public class ComplexFloatMatrix {
 
         /** Get matrix element, passing the variable to store the result. */
         public ComplexFloat get(int rowIndex, int columnIndex, ComplexFloat result) {
-            return get(index(rowIndex, columnIndex));
+            return get(index(rowIndex, columnIndex), result);
         }
 	
 	public FloatMatrix getReal() {
diff --git a/src/org/jblas/ConvertsToDoubleMatrix.java b/src/main/java/org/jblas/ConvertsToDoubleMatrix.java
similarity index 100%
rename from src/org/jblas/ConvertsToDoubleMatrix.java
rename to src/main/java/org/jblas/ConvertsToDoubleMatrix.java
diff --git a/src/org/jblas/ConvertsToFloatMatrix.java b/src/main/java/org/jblas/ConvertsToFloatMatrix.java
similarity index 100%
rename from src/org/jblas/ConvertsToFloatMatrix.java
rename to src/main/java/org/jblas/ConvertsToFloatMatrix.java
diff --git a/src/org/jblas/Decompose.java b/src/main/java/org/jblas/Decompose.java
similarity index 100%
rename from src/org/jblas/Decompose.java
rename to src/main/java/org/jblas/Decompose.java
diff --git a/src/org/jblas/DoubleFunction.java b/src/main/java/org/jblas/DoubleFunction.java
similarity index 100%
rename from src/org/jblas/DoubleFunction.java
rename to src/main/java/org/jblas/DoubleFunction.java
diff --git a/src/org/jblas/DoubleMatrix.java b/src/main/java/org/jblas/DoubleMatrix.java
similarity index 99%
rename from src/org/jblas/DoubleMatrix.java
rename to src/main/java/org/jblas/DoubleMatrix.java
index b1bf24a..0109047 100644
--- a/src/org/jblas/DoubleMatrix.java
+++ b/src/main/java/org/jblas/DoubleMatrix.java
@@ -91,8 +91,8 @@ import java.util.List;
  * <tr><th>Method<th>Description
  * <tr><td>DoubleMatrix(m)<td>Constructs a column vector.
  * <tr><td>DoubleMatrix(new double[] {value1, value2, ...})<td>Constructs a column vector.
- * <tr><td>DoubleMatrix.zeros(m) <td>Initial values set to 1.0.
- * <tr><td>DoubleMatrix.ones(m) <td>Initial values set to 0.0.
+ * <tr><td>DoubleMatrix.zeros(m) <td>Initial values set to 0.0.
+ * <tr><td>DoubleMatrix.ones(m) <td>Initial values set to 1.0.
  * <tr><td>DoubleMatrix.rand(m) <td>Values drawn at random between 0.0 and 1.0.
  * <tr><td>DoubleMatrix.randn(m) <td>Values drawn from normal distribution.
  * </table>
@@ -835,6 +835,7 @@ public class DoubleMatrix implements Serializable {
         }
     }
 
+
     /** Set elements in linear ordering in the specified indices. */
     public DoubleMatrix put(int[] indices, DoubleMatrix x) {
         if (x.isScalar()) {
diff --git a/src/main/java/org/jblas/Eigen.java b/src/main/java/org/jblas/Eigen.java
new file mode 100644
index 0000000..b0b1569
--- /dev/null
+++ b/src/main/java/org/jblas/Eigen.java
@@ -0,0 +1,271 @@
+// --- BEGIN LICENSE BLOCK ---
+/* 
+ * Copyright (c) 2009-2011, Mikio L. Braun
+ *               2011, Nicolas Oury
+ * 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.
+ */
+// --- END LICENSE BLOCK ---
+
+package org.jblas;
+
+/**
+ * <p>Eigenvalue and Eigenvector related functions.</p>
+ * <p/>
+ * <p>Methods exist for working with symmetric matrices or general eigenvalues.
+ * The symmetric versions are usually much faster on symmetric matrices.</p>
+ */
+public class Eigen {
+    private static final DoubleMatrix dummyDouble = new DoubleMatrix(1);
+
+    /**
+     * Compute the eigenvalues for a symmetric matrix.
+     */
+    public static DoubleMatrix symmetricEigenvalues(DoubleMatrix A) {
+        A.assertSquare();
+        DoubleMatrix eigenvalues = new DoubleMatrix(A.rows);
+        int isuppz[] = new int[2 * A.rows];
+        SimpleBlas.syevr('N', 'A', 'U', A.dup(), 0, 0, 0, 0, 0, eigenvalues, dummyDouble, isuppz);
+        return eigenvalues;
+    }
+
+    /**
+     * Computes the eigenvalues and eigenvectors for a symmetric matrix.
+     *
+     * @return an array of DoubleMatrix objects containing the eigenvectors
+     *         stored as the columns of the first matrix, and the eigenvalues as
+     *         diagonal elements of the second matrix.
+     */
+    public static DoubleMatrix[] symmetricEigenvectors(DoubleMatrix A) {
+        A.assertSquare();
+        DoubleMatrix eigenvalues = new DoubleMatrix(A.rows);
+        DoubleMatrix eigenvectors = A.dup();
+        int isuppz[] = new int[2 * A.rows];
+        SimpleBlas.syevr('V', 'A', 'U', A.dup(), 0, 0, 0, 0, 0, eigenvalues, eigenvectors, isuppz);
+        return new DoubleMatrix[]{eigenvectors, DoubleMatrix.diag(eigenvalues)};
+    }
+
+    /**
+     * Computes the eigenvalues of a general matrix.
+     */
+    public static ComplexDoubleMatrix eigenvalues(DoubleMatrix A) {
+        A.assertSquare();
+        DoubleMatrix WR = new DoubleMatrix(A.rows);
+        DoubleMatrix WI = WR.dup();
+        SimpleBlas.geev('N', 'N', A.dup(), WR, WI, dummyDouble, dummyDouble);
+
+        return new ComplexDoubleMatrix(WR, WI);
+    }
+
+    /**
+     * Computes the eigenvalues and eigenvectors of a general matrix.
+     *
+     * @return an array of ComplexDoubleMatrix objects containing the eigenvectors
+     *         stored as the columns of the first matrix, and the eigenvalues as the
+     *         diagonal elements of the second matrix.
+     */
+    public static ComplexDoubleMatrix[] eigenvectors(DoubleMatrix A) {
+        A.assertSquare();
+        // setting up result arrays
+        DoubleMatrix WR = new DoubleMatrix(A.rows);
+        DoubleMatrix WI = WR.dup();
+        DoubleMatrix VR = new DoubleMatrix(A.rows, A.rows);
+
+        SimpleBlas.geev('N', 'V', A.dup(), WR, WI, dummyDouble, VR);
+
+        // transferring the result
+        ComplexDoubleMatrix E = new ComplexDoubleMatrix(WR, WI);
+        ComplexDoubleMatrix V = new ComplexDoubleMatrix(A.rows, A.rows);
+        //System.err.printf("VR = %s\n", VR.toString());
+        for (int i = 0; i < A.rows; i++) {
+            if (E.get(i).isReal()) {
+                V.putColumn(i, new ComplexDoubleMatrix(VR.getColumn(i)));
+            } else {
+                ComplexDoubleMatrix v = new ComplexDoubleMatrix(VR.getColumn(i), VR.getColumn(i + 1));
+                V.putColumn(i, v);
+                V.putColumn(i + 1, v.conji());
+                i += 1;
+            }
+        }
+        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
+     * @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.
+     */
+    public static DoubleMatrix[] symmetricGeneralizedEigenvectors(DoubleMatrix A, DoubleMatrix B) {
+        A.assertSquare();
+        B.assertSquare();
+        DoubleMatrix[] result = new DoubleMatrix[2];
+        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;
+    }
+
+//BEGIN
+  // The code below has been automatically generated.
+  // DO NOT EDIT!
+    private static final FloatMatrix dummyFloat = new FloatMatrix(1);
+
+    /**
+     * Compute the eigenvalues for a symmetric matrix.
+     */
+    public static FloatMatrix symmetricEigenvalues(FloatMatrix A) {
+        A.assertSquare();
+        FloatMatrix eigenvalues = new FloatMatrix(A.rows);
+        int isuppz[] = new int[2 * A.rows];
+        SimpleBlas.syevr('N', 'A', 'U', A.dup(), 0, 0, 0, 0, 0, eigenvalues, dummyFloat, isuppz);
+        return eigenvalues;
+    }
+
+    /**
+     * Computes the eigenvalues and eigenvectors for a symmetric matrix.
+     *
+     * @return an array of FloatMatrix objects containing the eigenvectors
+     *         stored as the columns of the first matrix, and the eigenvalues as
+     *         diagonal elements of the second matrix.
+     */
+    public static FloatMatrix[] symmetricEigenvectors(FloatMatrix A) {
+        A.assertSquare();
+        FloatMatrix eigenvalues = new FloatMatrix(A.rows);
+        FloatMatrix eigenvectors = A.dup();
+        int isuppz[] = new int[2 * A.rows];
+        SimpleBlas.syevr('V', 'A', 'U', A.dup(), 0, 0, 0, 0, 0, eigenvalues, eigenvectors, isuppz);
+        return new FloatMatrix[]{eigenvectors, FloatMatrix.diag(eigenvalues)};
+    }
+
+    /**
+     * Computes the eigenvalues of a general matrix.
+     */
+    public static ComplexFloatMatrix eigenvalues(FloatMatrix A) {
+        A.assertSquare();
+        FloatMatrix WR = new FloatMatrix(A.rows);
+        FloatMatrix WI = WR.dup();
+        SimpleBlas.geev('N', 'N', A.dup(), WR, WI, dummyFloat, dummyFloat);
+
+        return new ComplexFloatMatrix(WR, WI);
+    }
+
+    /**
+     * Computes the eigenvalues and eigenvectors of a general matrix.
+     *
+     * @return an array of ComplexFloatMatrix objects containing the eigenvectors
+     *         stored as the columns of the first matrix, and the eigenvalues as the
+     *         diagonal elements of the second matrix.
+     */
+    public static ComplexFloatMatrix[] eigenvectors(FloatMatrix A) {
+        A.assertSquare();
+        // setting up result arrays
+        FloatMatrix WR = new FloatMatrix(A.rows);
+        FloatMatrix WI = WR.dup();
+        FloatMatrix VR = new FloatMatrix(A.rows, A.rows);
+
+        SimpleBlas.geev('N', 'V', A.dup(), WR, WI, dummyFloat, VR);
+
+        // transferring the result
+        ComplexFloatMatrix E = new ComplexFloatMatrix(WR, WI);
+        ComplexFloatMatrix V = new ComplexFloatMatrix(A.rows, A.rows);
+        //System.err.printf("VR = %s\n", VR.toString());
+        for (int i = 0; i < A.rows; i++) {
+            if (E.get(i).isReal()) {
+                V.putColumn(i, new ComplexFloatMatrix(VR.getColumn(i)));
+            } else {
+                ComplexFloatMatrix v = new ComplexFloatMatrix(VR.getColumn(i), VR.getColumn(i + 1));
+                V.putColumn(i, v);
+                V.putColumn(i + 1, v.conji());
+                i += 1;
+            }
+        }
+        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
+     * @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.
+     */
+    public static FloatMatrix[] symmetricGeneralizedEigenvectors(FloatMatrix A, FloatMatrix B) {
+        A.assertSquare();
+        B.assertSquare();
+        FloatMatrix[] result = new FloatMatrix[2];
+        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;
+    }
+
+//END
+}
diff --git a/src/org/jblas/FloatFunction.java b/src/main/java/org/jblas/FloatFunction.java
similarity index 100%
rename from src/org/jblas/FloatFunction.java
rename to src/main/java/org/jblas/FloatFunction.java
diff --git a/src/org/jblas/FloatMatrix.java b/src/main/java/org/jblas/FloatMatrix.java
similarity index 99%
rename from src/org/jblas/FloatMatrix.java
rename to src/main/java/org/jblas/FloatMatrix.java
index 0e381a1..1251a39 100644
--- a/src/org/jblas/FloatMatrix.java
+++ b/src/main/java/org/jblas/FloatMatrix.java
@@ -91,8 +91,8 @@ import java.util.List;
  * <tr><th>Method<th>Description
  * <tr><td>FloatMatrix(m)<td>Constructs a column vector.
  * <tr><td>FloatMatrix(new float[] {value1, value2, ...})<td>Constructs a column vector.
- * <tr><td>FloatMatrix.zeros(m) <td>Initial values set to 1.0f.
- * <tr><td>FloatMatrix.ones(m) <td>Initial values set to 0.0f.
+ * <tr><td>FloatMatrix.zeros(m) <td>Initial values set to 0.0f.
+ * <tr><td>FloatMatrix.ones(m) <td>Initial values set to 1.0f.
  * <tr><td>FloatMatrix.rand(m) <td>Values drawn at random between 0.0f and 1.0f.
  * <tr><td>FloatMatrix.randn(m) <td>Values drawn from normal distribution.
  * </table>
@@ -835,6 +835,7 @@ public class FloatMatrix implements Serializable {
         }
     }
 
+
     /** Set elements in linear ordering in the specified indices. */
     public FloatMatrix put(int[] indices, FloatMatrix x) {
         if (x.isScalar()) {
diff --git a/src/org/jblas/Geometry.java b/src/main/java/org/jblas/Geometry.java
similarity index 100%
rename from src/org/jblas/Geometry.java
rename to src/main/java/org/jblas/Geometry.java
diff --git a/src/org/jblas/JavaBlas.java b/src/main/java/org/jblas/JavaBlas.java
similarity index 100%
rename from src/org/jblas/JavaBlas.java
rename to src/main/java/org/jblas/JavaBlas.java
diff --git a/src/org/jblas/MatrixFunctions.java b/src/main/java/org/jblas/MatrixFunctions.java
similarity index 100%
rename from src/org/jblas/MatrixFunctions.java
rename to src/main/java/org/jblas/MatrixFunctions.java
diff --git a/src/org/jblas/NativeBlas.java b/src/main/java/org/jblas/NativeBlas.java
similarity index 93%
rename from src/org/jblas/NativeBlas.java
rename to src/main/java/org/jblas/NativeBlas.java
index 7dd6e00..32fb7fb 100644
--- a/src/org/jblas/NativeBlas.java
+++ b/src/main/java/org/jblas/NativeBlas.java
@@ -393,5 +393,37 @@ public class NativeBlas {
     return info;
   }
 
+  public static native int dsygvd(int itype, char jobz, char uplo, int n, double[] a, int aIdx, int lda, double[] b, int bIdx, int ldb, double[] w, int wIdx, double[] work, int workIdx, int lwork, int[] iwork, int iworkIdx, int liwork);
+  public static int dsygvd(int itype, char jobz, char uplo, int n, double[] a, int aIdx, int lda, double[] b, int bIdx, int ldb, double[] w, int wIdx) {
+    int info;
+    double[] work = new double[1];
+    int lwork;
+    int[] iwork = new int[1];
+    int liwork;
+    info = dsygvd(itype, jobz, uplo, n, doubleDummy, 0, lda, doubleDummy, 0, ldb, doubleDummy, 0, work, 0, -1, iwork, 0, -1);
+    if (info != 0)
+      return info;
+    lwork = (int) work[0]; work = new double[lwork];
+    liwork = (int) iwork[0]; iwork = new int[liwork];
+    info = dsygvd(itype, jobz, uplo, n, a, aIdx, lda, b, bIdx, ldb, w, wIdx, work, 0, lwork, iwork, 0, liwork);
+    return info;
+  }
+
+  public static native int ssygvd(int itype, char jobz, char uplo, int n, float[] a, int aIdx, int lda, float[] b, int bIdx, int ldb, float[] w, int wIdx, float[] work, int workIdx, int lwork, int[] iwork, int iworkIdx, int liwork);
+  public static int ssygvd(int itype, char jobz, char uplo, int n, float[] a, int aIdx, int lda, float[] b, int bIdx, int ldb, float[] w, int wIdx) {
+    int info;
+    float[] work = new float[1];
+    int lwork;
+    int[] iwork = new int[1];
+    int liwork;
+    info = ssygvd(itype, jobz, uplo, n, floatDummy, 0, lda, floatDummy, 0, ldb, floatDummy, 0, work, 0, -1, iwork, 0, -1);
+    if (info != 0)
+      return info;
+    lwork = (int) work[0]; work = new float[lwork];
+    liwork = (int) iwork[0]; iwork = new int[liwork];
+    info = ssygvd(itype, jobz, uplo, n, a, aIdx, lda, b, bIdx, ldb, w, wIdx, work, 0, lwork, iwork, 0, liwork);
+    return info;
+  }
+
 
 }
diff --git a/src/main/java/org/jblas/SimpleBlas.java b/src/main/java/org/jblas/SimpleBlas.java
new file mode 100644
index 0000000..56a7b93
--- /dev/null
+++ b/src/main/java/org/jblas/SimpleBlas.java
@@ -0,0 +1,732 @@
+// --- BEGIN LICENSE BLOCK ---
+/* 
+ * Copyright (c) 2009-2011, Mikio L. Braun
+ *               2011, Nicolas Oury
+ * 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.
+ */
+// --- END LICENSE BLOCK ---
+
+package org.jblas;
+
+import org.jblas.exceptions.LapackException;
+import org.jblas.exceptions.LapackArgumentException;
+import org.jblas.exceptions.LapackConvergenceException;
+import org.jblas.exceptions.LapackSingularityException;
+
+//import edu.ida.core.OutputValue;
+
+/**
+ * This class provides a cleaner direct interface to the BLAS routines by
+ * extracting the parameters of the matrices from the matrices itself.
+ * <p/>
+ * For example, you can just pass the vector and do not have to pass the length,
+ * corresponding DoubleBuffer, offset and step size explicitly.
+ * <p/>
+ * Currently, all the general matrix routines are implemented.
+ */
+public class SimpleBlas {
+    /***************************************************************************
+     * BLAS Level 1
+     */
+
+    /**
+     * Compute x <-> y (swap two matrices)
+     */
+    public static DoubleMatrix swap(DoubleMatrix x, DoubleMatrix y) {
+        //NativeBlas.dswap(x.length, x.data, 0, 1, y.data, 0, 1);
+        JavaBlas.rswap(x.length, x.data, 0, 1, y.data, 0, 1);
+        return y;
+    }
+
+    /**
+     * Compute x <- alpha * x (scale a matrix)
+     */
+    public static DoubleMatrix scal(double alpha, DoubleMatrix x) {
+        NativeBlas.dscal(x.length, alpha, x.data, 0, 1);
+        return x;
+    }
+
+    public static ComplexDoubleMatrix scal(ComplexDouble alpha, ComplexDoubleMatrix x) {
+        NativeBlas.zscal(x.length, alpha, x.data, 0, 1);
+        return x;
+    }
+
+    /**
+     * Compute y <- x (copy a matrix)
+     */
+    public static DoubleMatrix copy(DoubleMatrix x, DoubleMatrix y) {
+        //NativeBlas.dcopy(x.length, x.data, 0, 1, y.data, 0, 1);
+        JavaBlas.rcopy(x.length, x.data, 0, 1, y.data, 0, 1);
+        return y;
+    }
+
+    public static ComplexDoubleMatrix copy(ComplexDoubleMatrix x, ComplexDoubleMatrix y) {
+        NativeBlas.zcopy(x.length, x.data, 0, 1, y.data, 0, 1);
+        return y;
+    }
+
+    /**
+     * Compute y <- alpha * x + y (elementwise addition)
+     */
+    public static DoubleMatrix axpy(double da, DoubleMatrix dx, DoubleMatrix dy) {
+        //NativeBlas.daxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
+        JavaBlas.raxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
+
+        return dy;
+    }
+
+    public static ComplexDoubleMatrix axpy(ComplexDouble da, ComplexDoubleMatrix dx, ComplexDoubleMatrix dy) {
+        NativeBlas.zaxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
+        return dy;
+    }
+
+    /**
+     * Compute x^T * y (dot product)
+     */
+    public static double dot(DoubleMatrix x, DoubleMatrix y) {
+        //return NativeBlas.ddot(x.length, x.data, 0, 1, y.data, 0, 1);
+        return JavaBlas.rdot(x.length, x.data, 0, 1, y.data, 0, 1);
+    }
+
+    /**
+     * Compute x^T * y (dot product)
+     */
+    public static ComplexDouble dotc(ComplexDoubleMatrix x, ComplexDoubleMatrix y) {
+        return NativeBlas.zdotc(x.length, x.data, 0, 1, y.data, 0, 1);
+    }
+
+    /**
+     * Compute x^T * y (dot product)
+     */
+    public static ComplexDouble dotu(ComplexDoubleMatrix x, ComplexDoubleMatrix y) {
+        return NativeBlas.zdotu(x.length, x.data, 0, 1, y.data, 0, 1);
+    }
+
+    /**
+     * Compute || x ||_2 (2-norm)
+     */
+    public static double nrm2(DoubleMatrix x) {
+        return NativeBlas.dnrm2(x.length, x.data, 0, 1);
+    }
+
+    public static double nrm2(ComplexDoubleMatrix x) {
+        return NativeBlas.dznrm2(x.length, x.data, 0, 1);
+    }
+
+    /**
+     * Compute || x ||_1 (1-norm, sum of absolute values)
+     */
+    public static double asum(DoubleMatrix x) {
+        return NativeBlas.dasum(x.length, x.data, 0, 1);
+    }
+
+    public static double asum(ComplexDoubleMatrix x) {
+        return NativeBlas.dzasum(x.length, x.data, 0, 1);
+    }
+
+    /**
+     * Compute index of element with largest absolute value (index of absolute
+     * value maximum)
+     */
+    public static int iamax(DoubleMatrix x) {
+        return NativeBlas.idamax(x.length, x.data, 0, 1) - 1;
+    }
+
+    public static int iamax(ComplexDoubleMatrix x) {
+        return NativeBlas.izamax(x.length, x.data, 0, 1);
+    }
+
+    /***************************************************************************
+     * BLAS Level 2
+     */
+
+    /**
+     * Compute y <- alpha*op(a)*x + beta * y (general matrix vector
+     * multiplication)
+     */
+    public static DoubleMatrix gemv(double alpha, DoubleMatrix a,
+                                    DoubleMatrix x, double beta, DoubleMatrix y) {
+        if (false) {
+            NativeBlas.dgemv('N', a.rows, a.columns, alpha, a.data, 0, a.rows, x.data, 0,
+                    1, beta, y.data, 0, 1);
+        } else {
+            if (beta == 0.0) {
+                for (int i = 0; i < y.length; i++)
+                    y.data[i] = 0.0;
+
+                for (int j = 0; j < a.columns; j++) {
+                    double xj = x.get(j);
+                    if (xj != 0.0) {
+                        for (int i = 0; i < a.rows; i++)
+                            y.data[i] += a.get(i, j) * xj;
+                    }
+                }
+            } else {
+                for (int j = 0; j < a.columns; j++) {
+                    double byj = beta * y.data[j];
+                    double xj = x.get(j);
+                    for (int i = 0; i < a.rows; i++)
+                        y.data[j] = a.get(i, j) * xj + byj;
+                }
+            }
+        }
+        return y;
+    }
+
+    /**
+     * Compute A <- alpha * x * y^T + A (general rank-1 update)
+     */
+    public static DoubleMatrix ger(double alpha, DoubleMatrix x,
+                                   DoubleMatrix y, DoubleMatrix a) {
+        NativeBlas.dger(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
+                0, a.rows);
+        return a;
+    }
+
+    /**
+     * Compute A <- alpha * x * y^T + A (general rank-1 update)
+     */
+    public static ComplexDoubleMatrix geru(ComplexDouble alpha, ComplexDoubleMatrix x,
+                                           ComplexDoubleMatrix y, ComplexDoubleMatrix a) {
+        NativeBlas.zgeru(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
+                0, a.rows);
+        return a;
+    }
+
+    /**
+     * Compute A <- alpha * x * y^H + A (general rank-1 update)
+     */
+    public static ComplexDoubleMatrix gerc(ComplexDouble alpha, ComplexDoubleMatrix x,
+                                           ComplexDoubleMatrix y, ComplexDoubleMatrix a) {
+        NativeBlas.zgerc(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
+                0, a.rows);
+        return a;
+    }
+
+    /***************************************************************************
+     * BLAS Level 3
+     */
+
+    /**
+     * Compute c <- a*b + beta * c (general matrix matrix
+     * multiplication)
+     */
+    public static DoubleMatrix gemm(double alpha, DoubleMatrix a,
+                                    DoubleMatrix b, double beta, DoubleMatrix c) {
+        NativeBlas.dgemm('N', 'N', c.rows, c.columns, a.columns, alpha, a.data, 0,
+                a.rows, b.data, 0, b.rows, beta, c.data, 0, c.rows);
+        return c;
+    }
+
+    public static ComplexDoubleMatrix gemm(ComplexDouble alpha, ComplexDoubleMatrix a,
+                                           ComplexDoubleMatrix b, ComplexDouble beta, ComplexDoubleMatrix c) {
+        NativeBlas.zgemm('N', 'N', c.rows, c.columns, a.columns, alpha, a.data, 0,
+                a.rows, b.data, 0, b.rows, beta, c.data, 0, c.rows);
+        return c;
+    }
+
+	/***************************************************************************
+     * LAPACK
+     */
+
+    public static DoubleMatrix gesv(DoubleMatrix a, int[] ipiv,
+                                    DoubleMatrix b) {
+        int info = NativeBlas.dgesv(a.rows, b.columns, a.data, 0, a.rows, ipiv, 0,
+                b.data, 0, b.rows);
+        checkInfo("DGESV", info);
+
+        if (info > 0)
+            throw new LapackException("DGESV",
+                    "Linear equation cannot be solved because the matrix was singular.");
+
+        return b;
+    }
+
+//STOP
+
+    private static void checkInfo(String name, int info) {
+        if (info < -1)
+            throw new LapackArgumentException(name, info);
+    }
+//START
+
+    public static DoubleMatrix sysv(char uplo, DoubleMatrix a, int[] ipiv,
+                                    DoubleMatrix b) {
+        int info = NativeBlas.dsysv(uplo, a.rows, b.columns, a.data, 0, a.rows, ipiv, 0,
+                b.data, 0, b.rows);
+        checkInfo("SYSV", info);
+
+        if (info > 0)
+            throw new LapackSingularityException("SYV",
+                    "Linear equation cannot be solved because the matrix was singular.");
+
+        return b;
+    }
+
+    public static int syev(char jobz, char uplo, DoubleMatrix a, DoubleMatrix w) {
+        int info = NativeBlas.dsyev(jobz, uplo, a.rows, a.data, 0, a.rows, w.data, 0);
+
+        if (info > 0)
+            throw new LapackConvergenceException("SYEV",
+                    "Eigenvalues could not be computed " + info
+                            + " off-diagonal elements did not converge");
+
+        return info;
+    }
+
+    public static int syevx(char jobz, char range, char uplo, DoubleMatrix a,
+                            double vl, double vu, int il, int iu, double abstol,
+                            DoubleMatrix w, DoubleMatrix z) {
+        int n = a.rows;
+        int[] iwork = new int[5 * n];
+        int[] ifail = new int[n];
+        int[] m = new int[1];
+        int info;
+
+        info = NativeBlas.dsyevx(jobz, range, uplo, n, a.data, 0, a.rows, vl, vu, il,
+                iu, abstol, m, 0, w.data, 0, z.data, 0, z.rows, iwork, 0, ifail, 0);
+
+        if (info > 0) {
+            StringBuilder msg = new StringBuilder();
+            msg
+                    .append("Not all eigenvalues converged. Non-converging eigenvalues were: ");
+            for (int i = 0; i < info; i++) {
+                if (i > 0)
+                    msg.append(", ");
+                msg.append(ifail[i]);
+            }
+            msg.append(".");
+            throw new LapackConvergenceException("SYEVX", msg.toString());
+        }
+
+        return info;
+    }
+
+    public static int syevd(char jobz, char uplo, DoubleMatrix A,
+                            DoubleMatrix w) {
+        int n = A.rows;
+
+        int info = NativeBlas.dsyevd(jobz, uplo, n, A.data, 0, A.rows, w.data, 0);
+
+        if (info > 0)
+            throw new LapackConvergenceException("SYEVD", "Not all eigenvalues converged.");
+
+        return info;
+    }
+
+    public static int syevr(char jobz, char range, char uplo, DoubleMatrix a,
+                            double vl, double vu, int il, int iu, double abstol,
+                            DoubleMatrix w, DoubleMatrix z, int[] isuppz) {
+        int n = a.rows;
+        int[] m = new int[1];
+
+        int info = NativeBlas.dsyevr(jobz, range, uplo, n, a.data, 0, a.rows, vl, vu,
+                il, iu, abstol, m, 0, w.data, 0, z.data, 0, z.rows, isuppz, 0);
+
+        checkInfo("SYEVR", info);
+
+        return info;
+    }
+
+    public static void posv(char uplo, DoubleMatrix A, DoubleMatrix B) {
+        int n = A.rows;
+        int nrhs = B.columns;
+        int info = NativeBlas.dposv(uplo, n, nrhs, A.data, 0, A.rows, B.data, 0,
+                B.rows);
+        checkInfo("DPOSV", info);
+        if (info > 0)
+            throw new LapackArgumentException("DPOSV",
+                    "Leading minor of order i of A is not positive definite.");
+    }
+
+    public static int geev(char jobvl, char jobvr, DoubleMatrix A,
+                           DoubleMatrix WR, DoubleMatrix WI, DoubleMatrix VL, DoubleMatrix VR) {
+        int info = NativeBlas.dgeev(jobvl, jobvr, A.rows, A.data, 0, A.rows, WR.data, 0,
+                WI.data, 0, VL.data, 0, VL.rows, VR.data, 0, VR.rows);
+        if (info > 0)
+            throw new LapackConvergenceException("DGEEV", "First " + info + " eigenvalues have not converged.");
+        return info;
+    }
+
+    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 {
+            if (info < 0)
+                throw new LapackArgumentException("DSYGVD", -info);
+            if (info <= A.rows && jobz == 'N')
+                throw new LapackConvergenceException("DSYGVD", info + " off-diagonal elements did not converge to 0.");
+            if (info <= A.rows && jobz == 'V')
+                throw new LapackException("DSYGVD", "Failed to compute an eigenvalue while working on a sub-matrix  " + info + ".");
+            else
+                throw new LapackException("DSYGVD", "The leading minor of order " + (info - A.rows) + " of B is not positive definite.");
+        }
+    }
+
+//BEGIN
+  // The code below has been automatically generated.
+  // DO NOT EDIT!
+    /***************************************************************************
+     * BLAS Level 1
+     */
+
+    /**
+     * Compute x <-> y (swap two matrices)
+     */
+    public static FloatMatrix swap(FloatMatrix x, FloatMatrix y) {
+        //NativeBlas.sswap(x.length, x.data, 0, 1, y.data, 0, 1);
+        JavaBlas.rswap(x.length, x.data, 0, 1, y.data, 0, 1);
+        return y;
+    }
+
+    /**
+     * Compute x <- alpha * x (scale a matrix)
+     */
+    public static FloatMatrix scal(float alpha, FloatMatrix x) {
+        NativeBlas.sscal(x.length, alpha, x.data, 0, 1);
+        return x;
+    }
+
+    public static ComplexFloatMatrix scal(ComplexFloat alpha, ComplexFloatMatrix x) {
+        NativeBlas.cscal(x.length, alpha, x.data, 0, 1);
+        return x;
+    }
+
+    /**
+     * Compute y <- x (copy a matrix)
+     */
+    public static FloatMatrix copy(FloatMatrix x, FloatMatrix y) {
+        //NativeBlas.scopy(x.length, x.data, 0, 1, y.data, 0, 1);
+        JavaBlas.rcopy(x.length, x.data, 0, 1, y.data, 0, 1);
+        return y;
+    }
+
+    public static ComplexFloatMatrix copy(ComplexFloatMatrix x, ComplexFloatMatrix y) {
+        NativeBlas.ccopy(x.length, x.data, 0, 1, y.data, 0, 1);
+        return y;
+    }
+
+    /**
+     * Compute y <- alpha * x + y (elementwise addition)
+     */
+    public static FloatMatrix axpy(float da, FloatMatrix dx, FloatMatrix dy) {
+        //NativeBlas.saxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
+        JavaBlas.raxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
+
+        return dy;
+    }
+
+    public static ComplexFloatMatrix axpy(ComplexFloat da, ComplexFloatMatrix dx, ComplexFloatMatrix dy) {
+        NativeBlas.caxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
+        return dy;
+    }
+
+    /**
+     * Compute x^T * y (dot product)
+     */
+    public static float dot(FloatMatrix x, FloatMatrix y) {
+        //return NativeBlas.sdot(x.length, x.data, 0, 1, y.data, 0, 1);
+        return JavaBlas.rdot(x.length, x.data, 0, 1, y.data, 0, 1);
+    }
+
+    /**
+     * Compute x^T * y (dot product)
+     */
+    public static ComplexFloat dotc(ComplexFloatMatrix x, ComplexFloatMatrix y) {
+        return NativeBlas.cdotc(x.length, x.data, 0, 1, y.data, 0, 1);
+    }
+
+    /**
+     * Compute x^T * y (dot product)
+     */
+    public static ComplexFloat dotu(ComplexFloatMatrix x, ComplexFloatMatrix y) {
+        return NativeBlas.cdotu(x.length, x.data, 0, 1, y.data, 0, 1);
+    }
+
+    /**
+     * Compute || x ||_2 (2-norm)
+     */
+    public static float nrm2(FloatMatrix x) {
+        return NativeBlas.snrm2(x.length, x.data, 0, 1);
+    }
+
+    public static float nrm2(ComplexFloatMatrix x) {
+        return NativeBlas.scnrm2(x.length, x.data, 0, 1);
+    }
+
+    /**
+     * Compute || x ||_1 (1-norm, sum of absolute values)
+     */
+    public static float asum(FloatMatrix x) {
+        return NativeBlas.sasum(x.length, x.data, 0, 1);
+    }
+
+    public static float asum(ComplexFloatMatrix x) {
+        return NativeBlas.scasum(x.length, x.data, 0, 1);
+    }
+
+    /**
+     * Compute index of element with largest absolute value (index of absolute
+     * value maximum)
+     */
+    public static int iamax(FloatMatrix x) {
+        return NativeBlas.isamax(x.length, x.data, 0, 1) - 1;
+    }
+
+    public static int iamax(ComplexFloatMatrix x) {
+        return NativeBlas.icamax(x.length, x.data, 0, 1);
+    }
+
+    /***************************************************************************
+     * BLAS Level 2
+     */
+
+    /**
+     * Compute y <- alpha*op(a)*x + beta * y (general matrix vector
+     * multiplication)
+     */
+    public static FloatMatrix gemv(float alpha, FloatMatrix a,
+                                    FloatMatrix x, float beta, FloatMatrix y) {
+        if (false) {
+            NativeBlas.sgemv('N', a.rows, a.columns, alpha, a.data, 0, a.rows, x.data, 0,
+                    1, beta, y.data, 0, 1);
+        } else {
+            if (beta == 0.0f) {
+                for (int i = 0; i < y.length; i++)
+                    y.data[i] = 0.0f;
+
+                for (int j = 0; j < a.columns; j++) {
+                    float xj = x.get(j);
+                    if (xj != 0.0f) {
+                        for (int i = 0; i < a.rows; i++)
+                            y.data[i] += a.get(i, j) * xj;
+                    }
+                }
+            } else {
+                for (int j = 0; j < a.columns; j++) {
+                    float byj = beta * y.data[j];
+                    float xj = x.get(j);
+                    for (int i = 0; i < a.rows; i++)
+                        y.data[j] = a.get(i, j) * xj + byj;
+                }
+            }
+        }
+        return y;
+    }
+
+    /**
+     * Compute A <- alpha * x * y^T + A (general rank-1 update)
+     */
+    public static FloatMatrix ger(float alpha, FloatMatrix x,
+                                   FloatMatrix y, FloatMatrix a) {
+        NativeBlas.sger(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
+                0, a.rows);
+        return a;
+    }
+
+    /**
+     * Compute A <- alpha * x * y^T + A (general rank-1 update)
+     */
+    public static ComplexFloatMatrix geru(ComplexFloat alpha, ComplexFloatMatrix x,
+                                           ComplexFloatMatrix y, ComplexFloatMatrix a) {
+        NativeBlas.cgeru(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
+                0, a.rows);
+        return a;
+    }
+
+    /**
+     * Compute A <- alpha * x * y^H + A (general rank-1 update)
+     */
+    public static ComplexFloatMatrix gerc(ComplexFloat alpha, ComplexFloatMatrix x,
+                                           ComplexFloatMatrix y, ComplexFloatMatrix a) {
+        NativeBlas.cgerc(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
+                0, a.rows);
+        return a;
+    }
+
+    /***************************************************************************
+     * BLAS Level 3
+     */
+
+    /**
+     * Compute c <- a*b + beta * c (general matrix matrix
+     * multiplication)
+     */
+    public static FloatMatrix gemm(float alpha, FloatMatrix a,
+                                    FloatMatrix b, float beta, FloatMatrix c) {
+        NativeBlas.sgemm('N', 'N', c.rows, c.columns, a.columns, alpha, a.data, 0,
+                a.rows, b.data, 0, b.rows, beta, c.data, 0, c.rows);
+        return c;
+    }
+
+    public static ComplexFloatMatrix gemm(ComplexFloat alpha, ComplexFloatMatrix a,
+                                           ComplexFloatMatrix b, ComplexFloat beta, ComplexFloatMatrix c) {
+        NativeBlas.cgemm('N', 'N', c.rows, c.columns, a.columns, alpha, a.data, 0,
+                a.rows, b.data, 0, b.rows, beta, c.data, 0, c.rows);
+        return c;
+    }
+
+	/***************************************************************************
+     * LAPACK
+     */
+
+    public static FloatMatrix gesv(FloatMatrix a, int[] ipiv,
+                                    FloatMatrix b) {
+        int info = NativeBlas.sgesv(a.rows, b.columns, a.data, 0, a.rows, ipiv, 0,
+                b.data, 0, b.rows);
+        checkInfo("DGESV", info);
+
+        if (info > 0)
+            throw new LapackException("DGESV",
+                    "Linear equation cannot be solved because the matrix was singular.");
+
+        return b;
+    }
+
+
+    public static FloatMatrix sysv(char uplo, FloatMatrix a, int[] ipiv,
+                                    FloatMatrix b) {
+        int info = NativeBlas.ssysv(uplo, a.rows, b.columns, a.data, 0, a.rows, ipiv, 0,
+                b.data, 0, b.rows);
+        checkInfo("SYSV", info);
+
+        if (info > 0)
+            throw new LapackSingularityException("SYV",
+                    "Linear equation cannot be solved because the matrix was singular.");
+
+        return b;
+    }
+
+    public static int syev(char jobz, char uplo, FloatMatrix a, FloatMatrix w) {
+        int info = NativeBlas.ssyev(jobz, uplo, a.rows, a.data, 0, a.rows, w.data, 0);
+
+        if (info > 0)
+            throw new LapackConvergenceException("SYEV",
+                    "Eigenvalues could not be computed " + info
+                            + " off-diagonal elements did not converge");
+
+        return info;
+    }
+
+    public static int syevx(char jobz, char range, char uplo, FloatMatrix a,
+                            float vl, float vu, int il, int iu, float abstol,
+                            FloatMatrix w, FloatMatrix z) {
+        int n = a.rows;
+        int[] iwork = new int[5 * n];
+        int[] ifail = new int[n];
+        int[] m = new int[1];
+        int info;
+
+        info = NativeBlas.ssyevx(jobz, range, uplo, n, a.data, 0, a.rows, vl, vu, il,
+                iu, abstol, m, 0, w.data, 0, z.data, 0, z.rows, iwork, 0, ifail, 0);
+
+        if (info > 0) {
+            StringBuilder msg = new StringBuilder();
+            msg
+                    .append("Not all eigenvalues converged. Non-converging eigenvalues were: ");
+            for (int i = 0; i < info; i++) {
+                if (i > 0)
+                    msg.append(", ");
+                msg.append(ifail[i]);
+            }
+            msg.append(".");
+            throw new LapackConvergenceException("SYEVX", msg.toString());
+        }
+
+        return info;
+    }
+
+    public static int syevd(char jobz, char uplo, FloatMatrix A,
+                            FloatMatrix w) {
+        int n = A.rows;
+
+        int info = NativeBlas.ssyevd(jobz, uplo, n, A.data, 0, A.rows, w.data, 0);
+
+        if (info > 0)
+            throw new LapackConvergenceException("SYEVD", "Not all eigenvalues converged.");
+
+        return info;
+    }
+
+    public static int syevr(char jobz, char range, char uplo, FloatMatrix a,
+                            float vl, float vu, int il, int iu, float abstol,
+                            FloatMatrix w, FloatMatrix z, int[] isuppz) {
+        int n = a.rows;
+        int[] m = new int[1];
+
+        int info = NativeBlas.ssyevr(jobz, range, uplo, n, a.data, 0, a.rows, vl, vu,
+                il, iu, abstol, m, 0, w.data, 0, z.data, 0, z.rows, isuppz, 0);
+
+        checkInfo("SYEVR", info);
+
+        return info;
+    }
+
+    public static void posv(char uplo, FloatMatrix A, FloatMatrix B) {
+        int n = A.rows;
+        int nrhs = B.columns;
+        int info = NativeBlas.sposv(uplo, n, nrhs, A.data, 0, A.rows, B.data, 0,
+                B.rows);
+        checkInfo("DPOSV", info);
+        if (info > 0)
+            throw new LapackArgumentException("DPOSV",
+                    "Leading minor of order i of A is not positive definite.");
+    }
+
+    public static int geev(char jobvl, char jobvr, FloatMatrix A,
+                           FloatMatrix WR, FloatMatrix WI, FloatMatrix VL, FloatMatrix VR) {
+        int info = NativeBlas.sgeev(jobvl, jobvr, A.rows, A.data, 0, A.rows, WR.data, 0,
+                WI.data, 0, VL.data, 0, VL.rows, VR.data, 0, VR.rows);
+        if (info > 0)
+            throw new LapackConvergenceException("DGEEV", "First " + info + " eigenvalues have not converged.");
+        return info;
+    }
+
+    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 {
+            if (info < 0)
+                throw new LapackArgumentException("DSYGVD", -info);
+            if (info <= A.rows && jobz == 'N')
+                throw new LapackConvergenceException("DSYGVD", info + " off-diagonal elements did not converge to 0.");
+            if (info <= A.rows && jobz == 'V')
+                throw new LapackException("DSYGVD", "Failed to compute an eigenvalue while working on a sub-matrix  " + info + ".");
+            else
+                throw new LapackException("DSYGVD", "The leading minor of order " + (info - A.rows) + " of B is not positive definite.");
+        }
+    }
+
+//END
+}
diff --git a/src/org/jblas/Singular.java b/src/main/java/org/jblas/Singular.java
similarity index 100%
rename from src/org/jblas/Singular.java
rename to src/main/java/org/jblas/Singular.java
diff --git a/src/org/jblas/Solve.java b/src/main/java/org/jblas/Solve.java
similarity index 100%
rename from src/org/jblas/Solve.java
rename to src/main/java/org/jblas/Solve.java
diff --git a/src/org/jblas/Trigonometry.java b/src/main/java/org/jblas/Trigonometry.java
similarity index 100%
rename from src/org/jblas/Trigonometry.java
rename to src/main/java/org/jblas/Trigonometry.java
diff --git a/src/org/jblas/benchmark/ATLASDoubleMultiplicationBenchmark.java b/src/main/java/org/jblas/benchmark/ATLASDoubleMultiplicationBenchmark.java
similarity index 100%
rename from src/org/jblas/benchmark/ATLASDoubleMultiplicationBenchmark.java
rename to src/main/java/org/jblas/benchmark/ATLASDoubleMultiplicationBenchmark.java
diff --git a/src/org/jblas/benchmark/ATLASFloatMultiplicationBenchmark.java b/src/main/java/org/jblas/benchmark/ATLASFloatMultiplicationBenchmark.java
similarity index 100%
rename from src/org/jblas/benchmark/ATLASFloatMultiplicationBenchmark.java
rename to src/main/java/org/jblas/benchmark/ATLASFloatMultiplicationBenchmark.java
diff --git a/src/org/jblas/benchmark/Benchmark.java b/src/main/java/org/jblas/benchmark/Benchmark.java
similarity index 100%
rename from src/org/jblas/benchmark/Benchmark.java
rename to src/main/java/org/jblas/benchmark/Benchmark.java
diff --git a/src/org/jblas/benchmark/BenchmarkResult.java b/src/main/java/org/jblas/benchmark/BenchmarkResult.java
similarity index 100%
rename from src/org/jblas/benchmark/BenchmarkResult.java
rename to src/main/java/org/jblas/benchmark/BenchmarkResult.java
diff --git a/src/org/jblas/benchmark/JavaDoubleMultiplicationBenchmark.java b/src/main/java/org/jblas/benchmark/JavaDoubleMultiplicationBenchmark.java
similarity index 100%
rename from src/org/jblas/benchmark/JavaDoubleMultiplicationBenchmark.java
rename to src/main/java/org/jblas/benchmark/JavaDoubleMultiplicationBenchmark.java
diff --git a/src/org/jblas/benchmark/JavaFloatMultiplicationBenchmark.java b/src/main/java/org/jblas/benchmark/JavaFloatMultiplicationBenchmark.java
similarity index 100%
rename from src/org/jblas/benchmark/JavaFloatMultiplicationBenchmark.java
rename to src/main/java/org/jblas/benchmark/JavaFloatMultiplicationBenchmark.java
diff --git a/src/org/jblas/benchmark/Main.java b/src/main/java/org/jblas/benchmark/Main.java
similarity index 100%
rename from src/org/jblas/benchmark/Main.java
rename to src/main/java/org/jblas/benchmark/Main.java
diff --git a/src/org/jblas/benchmark/Timer.java b/src/main/java/org/jblas/benchmark/Timer.java
similarity index 100%
rename from src/org/jblas/benchmark/Timer.java
rename to src/main/java/org/jblas/benchmark/Timer.java
diff --git a/src/org/jblas/benchmark/package-info.java b/src/main/java/org/jblas/benchmark/package-info.java
similarity index 100%
rename from src/org/jblas/benchmark/package-info.java
rename to src/main/java/org/jblas/benchmark/package-info.java
diff --git a/src/org/jblas/exceptions/LapackArgumentException.java b/src/main/java/org/jblas/exceptions/LapackArgumentException.java
similarity index 100%
rename from src/org/jblas/exceptions/LapackArgumentException.java
rename to src/main/java/org/jblas/exceptions/LapackArgumentException.java
diff --git a/src/org/jblas/exceptions/LapackConvergenceException.java b/src/main/java/org/jblas/exceptions/LapackConvergenceException.java
similarity index 100%
rename from src/org/jblas/exceptions/LapackConvergenceException.java
rename to src/main/java/org/jblas/exceptions/LapackConvergenceException.java
diff --git a/src/org/jblas/exceptions/LapackException.java b/src/main/java/org/jblas/exceptions/LapackException.java
similarity index 100%
rename from src/org/jblas/exceptions/LapackException.java
rename to src/main/java/org/jblas/exceptions/LapackException.java
diff --git a/src/org/jblas/exceptions/LapackPositivityException.java b/src/main/java/org/jblas/exceptions/LapackPositivityException.java
similarity index 100%
rename from src/org/jblas/exceptions/LapackPositivityException.java
rename to src/main/java/org/jblas/exceptions/LapackPositivityException.java
diff --git a/src/org/jblas/exceptions/LapackSingularityException.java b/src/main/java/org/jblas/exceptions/LapackSingularityException.java
similarity index 100%
rename from src/org/jblas/exceptions/LapackSingularityException.java
rename to src/main/java/org/jblas/exceptions/LapackSingularityException.java
diff --git a/src/org/jblas/exceptions/SizeException.java b/src/main/java/org/jblas/exceptions/SizeException.java
similarity index 100%
rename from src/org/jblas/exceptions/SizeException.java
rename to src/main/java/org/jblas/exceptions/SizeException.java
diff --git a/src/org/jblas/exceptions/package-info.java b/src/main/java/org/jblas/exceptions/package-info.java
similarity index 100%
rename from src/org/jblas/exceptions/package-info.java
rename to src/main/java/org/jblas/exceptions/package-info.java
diff --git a/src/org/jblas/package-info.java b/src/main/java/org/jblas/package-info.java
similarity index 100%
rename from src/org/jblas/package-info.java
rename to src/main/java/org/jblas/package-info.java
diff --git a/src/org/jblas/ranges/AllRange.java b/src/main/java/org/jblas/ranges/AllRange.java
similarity index 100%
rename from src/org/jblas/ranges/AllRange.java
rename to src/main/java/org/jblas/ranges/AllRange.java
diff --git a/src/org/jblas/ranges/IndicesRange.java b/src/main/java/org/jblas/ranges/IndicesRange.java
similarity index 100%
rename from src/org/jblas/ranges/IndicesRange.java
rename to src/main/java/org/jblas/ranges/IndicesRange.java
diff --git a/src/org/jblas/ranges/IntervalRange.java b/src/main/java/org/jblas/ranges/IntervalRange.java
similarity index 100%
rename from src/org/jblas/ranges/IntervalRange.java
rename to src/main/java/org/jblas/ranges/IntervalRange.java
diff --git a/src/org/jblas/ranges/PointRange.java b/src/main/java/org/jblas/ranges/PointRange.java
similarity index 100%
rename from src/org/jblas/ranges/PointRange.java
rename to src/main/java/org/jblas/ranges/PointRange.java
diff --git a/src/org/jblas/ranges/Range.java b/src/main/java/org/jblas/ranges/Range.java
similarity index 100%
rename from src/org/jblas/ranges/Range.java
rename to src/main/java/org/jblas/ranges/Range.java
diff --git a/src/org/jblas/ranges/RangeUtils.java b/src/main/java/org/jblas/ranges/RangeUtils.java
similarity index 100%
rename from src/org/jblas/ranges/RangeUtils.java
rename to src/main/java/org/jblas/ranges/RangeUtils.java
diff --git a/src/org/jblas/ranges/package-info.java b/src/main/java/org/jblas/ranges/package-info.java
similarity index 100%
rename from src/org/jblas/ranges/package-info.java
rename to src/main/java/org/jblas/ranges/package-info.java
diff --git a/src/org/jblas/util/ArchFlavor.java b/src/main/java/org/jblas/util/ArchFlavor.java
similarity index 92%
rename from src/org/jblas/util/ArchFlavor.java
rename to src/main/java/org/jblas/util/ArchFlavor.java
index 42a3f8f..1438ff5 100644
--- a/src/org/jblas/util/ArchFlavor.java
+++ b/src/main/java/org/jblas/util/ArchFlavor.java
@@ -64,8 +64,12 @@ public class ArchFlavor {
             return fixedFlavor;
 
         String arch = System.getProperty("os.arch");
+        String name = System.getProperty("os.name");
 
-        if (arch.equals("i386") || arch.equals("x86") || arch.equals("x86_64") || arch.equals("amd64")) {
+        if (name.startsWith("Windows") && arch.equals("amd64")) {
+            return null;
+        }
+        else if(arch.equals("i386") || arch.equals("x86") || arch.equals("x86_64") || arch.equals("amd64")) {
             switch (SSELevel()) {
                 case SSE:
                     return "sse";
diff --git a/src/org/jblas/util/Functions.java b/src/main/java/org/jblas/util/Functions.java
similarity index 100%
rename from src/org/jblas/util/Functions.java
rename to src/main/java/org/jblas/util/Functions.java
diff --git a/src/org/jblas/util/LibraryLoader.java b/src/main/java/org/jblas/util/LibraryLoader.java
similarity index 100%
rename from src/org/jblas/util/LibraryLoader.java
rename to src/main/java/org/jblas/util/LibraryLoader.java
diff --git a/src/org/jblas/util/Logger.java b/src/main/java/org/jblas/util/Logger.java
similarity index 100%
rename from src/org/jblas/util/Logger.java
rename to src/main/java/org/jblas/util/Logger.java
diff --git a/src/org/jblas/util/Permutations.java b/src/main/java/org/jblas/util/Permutations.java
similarity index 100%
rename from src/org/jblas/util/Permutations.java
rename to src/main/java/org/jblas/util/Permutations.java
diff --git a/src/org/jblas/util/SanityChecks.java b/src/main/java/org/jblas/util/SanityChecks.java
similarity index 93%
rename from src/org/jblas/util/SanityChecks.java
rename to src/main/java/org/jblas/util/SanityChecks.java
index a64007b..43dbc72 100644
--- a/src/org/jblas/util/SanityChecks.java
+++ b/src/main/java/org/jblas/util/SanityChecks.java
@@ -1,6 +1,6 @@
 // --- BEGIN LICENSE BLOCK ---
 /*
- * Copyright (c) 2009, Mikio L. Braun
+ * Copyright (c) 2009-2011, Mikio L. Braun
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -149,6 +149,15 @@ public class SanityChecks {
         check("checking existence of dgesvd...", true);
     }
 
+    public static void checkGeneralizedEigenvalues() {
+        DoubleMatrix A = new DoubleMatrix(3, 3, 2.0, 1.0, 0.0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0);
+        DoubleMatrix B = new DoubleMatrix(3, 3, 4.0, 2.0, 1.0, 2.0, 4.0, 2.0, 1.0, 2.0, 4.0);
+
+        DoubleMatrix[] LA = org.jblas.Eigen.symmetricGeneralizedEigenvectors(A, B);
+
+        check("checkign existence of gsyevd (generalized eigenvalues)...", true);
+    }
+
     public static void checkComplexReturnValues() {
         double[] data = new double[] {
             1.0, 2.0, 3.0, 4.0, 5.0, 6.0
diff --git a/src/org/jblas/util/package-info.java b/src/main/java/org/jblas/util/package-info.java
similarity index 100%
rename from src/org/jblas/util/package-info.java
rename to src/main/java/org/jblas/util/package-info.java
diff --git a/src/overview.html b/src/main/java/overview.html
similarity index 100%
rename from src/overview.html
rename to src/main/java/overview.html
diff --git a/src/overview.textile b/src/main/java/overview.textile
similarity index 100%
rename from src/overview.textile
rename to src/main/java/overview.textile
diff --git a/src/main/resources/lib/static/Linux/amd64/libjblas_arch_flavor.so b/src/main/resources/lib/static/Linux/amd64/libjblas_arch_flavor.so
new file mode 100755
index 0000000..7a5d649
Binary files /dev/null and b/src/main/resources/lib/static/Linux/amd64/libjblas_arch_flavor.so differ
diff --git a/src/main/resources/lib/static/Linux/amd64/sse2/libjblas.so b/src/main/resources/lib/static/Linux/amd64/sse2/libjblas.so
new file mode 100755
index 0000000..569dfd5
Binary files /dev/null and b/src/main/resources/lib/static/Linux/amd64/sse2/libjblas.so differ
diff --git a/src/main/resources/lib/static/Linux/amd64/sse3/libjblas.so b/src/main/resources/lib/static/Linux/amd64/sse3/libjblas.so
new file mode 100755
index 0000000..3ddefec
Binary files /dev/null and b/src/main/resources/lib/static/Linux/amd64/sse3/libjblas.so differ
diff --git a/src/main/resources/lib/static/Linux/i386/libjblas_arch_flavor.so b/src/main/resources/lib/static/Linux/i386/libjblas_arch_flavor.so
new file mode 100755
index 0000000..01180d6
Binary files /dev/null and b/src/main/resources/lib/static/Linux/i386/libjblas_arch_flavor.so differ
diff --git a/src/main/resources/lib/static/Linux/i386/sse2/libjblas.so b/src/main/resources/lib/static/Linux/i386/sse2/libjblas.so
new file mode 100755
index 0000000..5425bd3
Binary files /dev/null and b/src/main/resources/lib/static/Linux/i386/sse2/libjblas.so differ
diff --git a/src/main/resources/lib/static/Linux/i386/sse3/libjblas.so b/src/main/resources/lib/static/Linux/i386/sse3/libjblas.so
new file mode 100755
index 0000000..4f988c6
Binary files /dev/null and b/src/main/resources/lib/static/Linux/i386/sse3/libjblas.so differ
diff --git a/src/main/resources/lib/static/Mac OS X/x86_64/libjblas_arch_flavor.jnilib b/src/main/resources/lib/static/Mac OS X/x86_64/libjblas_arch_flavor.jnilib
new file mode 100755
index 0000000..57caf20
Binary files /dev/null and b/src/main/resources/lib/static/Mac OS X/x86_64/libjblas_arch_flavor.jnilib differ
diff --git a/src/main/resources/lib/static/Mac OS X/x86_64/sse3/libjblas.jnilib b/src/main/resources/lib/static/Mac OS X/x86_64/sse3/libjblas.jnilib
new file mode 100755
index 0000000..ebab2a4
Binary files /dev/null and b/src/main/resources/lib/static/Mac OS X/x86_64/sse3/libjblas.jnilib differ
diff --git a/src/main/resources/lib/static/Windows/amd64/jblas.dll b/src/main/resources/lib/static/Windows/amd64/jblas.dll
new file mode 100755
index 0000000..62f8788
Binary files /dev/null and b/src/main/resources/lib/static/Windows/amd64/jblas.dll differ
diff --git a/src/main/resources/lib/static/Windows/amd64/jblas_arch_flavor.dll b/src/main/resources/lib/static/Windows/amd64/jblas_arch_flavor.dll
new file mode 100755
index 0000000..99742cf
Binary files /dev/null and b/src/main/resources/lib/static/Windows/amd64/jblas_arch_flavor.dll differ
diff --git a/src/main/resources/lib/static/Windows/x86/jblas_arch_flavor.dll b/src/main/resources/lib/static/Windows/x86/jblas_arch_flavor.dll
new file mode 100755
index 0000000..3844cd3
Binary files /dev/null and b/src/main/resources/lib/static/Windows/x86/jblas_arch_flavor.dll differ
diff --git a/src/main/resources/lib/static/Windows/x86/sse2/jblas.dll b/src/main/resources/lib/static/Windows/x86/sse2/jblas.dll
new file mode 100755
index 0000000..31f96eb
Binary files /dev/null and b/src/main/resources/lib/static/Windows/x86/sse2/jblas.dll differ
diff --git a/src/main/resources/lib/static/Windows/x86/sse3/jblas.dll b/src/main/resources/lib/static/Windows/x86/sse3/jblas.dll
new file mode 100755
index 0000000..f851925
Binary files /dev/null and b/src/main/resources/lib/static/Windows/x86/sse3/jblas.dll differ
diff --git a/src/org/jblas/Eigen.java b/src/org/jblas/Eigen.java
deleted file mode 100644
index 7e5de6e..0000000
--- a/src/org/jblas/Eigen.java
+++ /dev/null
@@ -1,190 +0,0 @@
-// --- BEGIN LICENSE BLOCK ---
-/* 
- * Copyright (c) 2009, Mikio L. Braun
- * 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.
- */
-// --- END LICENSE BLOCK ---
-
-package org.jblas;
-
-/**
- * <p>Eigenvalue and Eigenvector related functions.</p>
- * 
- * <p>Methods exist for working with symmetric matrices or general eigenvalues.
- * The symmetric versions are usually much faster on symmetric matrices.</p>
- */
-public class Eigen {
-        private static final DoubleMatrix dummyDouble = new DoubleMatrix(1);
-    
-        /** Compute the eigenvalues for a symmetric matrix. */
-	public static DoubleMatrix symmetricEigenvalues(DoubleMatrix A) {
-		A.assertSquare();
-		DoubleMatrix eigenvalues = new DoubleMatrix(A.rows);
-        int isuppz[] = new int[2*A.rows];
-		SimpleBlas.syevr('N', 'A', 'U', A.dup(), 0, 0, 0, 0, 0, eigenvalues, dummyDouble, isuppz);
-		return eigenvalues;
-	}
-
-        /** 
-         * Computes the eigenvalues and eigenvectors for a symmetric matrix. 
-         *
-         * @return an array of DoubleMatrix objects containing the eigenvectors 
-         * stored as the columns of the first matrix, and the eigenvalues as
-         * diagonal elements of the second matrix.
-         */
-	public static DoubleMatrix[] symmetricEigenvectors(DoubleMatrix A) {
-		A.assertSquare();
-		DoubleMatrix eigenvalues = new DoubleMatrix(A.rows);
-		DoubleMatrix eigenvectors = A.dup();
-        int isuppz[] = new int[2*A.rows];
-        SimpleBlas.syevr('V', 'A', 'U', A.dup(), 0, 0, 0, 0, 0, eigenvalues, eigenvectors, isuppz);
-		return new DoubleMatrix[] { eigenvectors, DoubleMatrix.diag(eigenvalues) };
-	}
-        
-        /** Computes the eigenvalues of a general matrix. */
-        public static ComplexDoubleMatrix eigenvalues(DoubleMatrix A) {
-            A.assertSquare();
-            DoubleMatrix WR = new DoubleMatrix(A.rows);
-            DoubleMatrix WI = WR.dup();
-            SimpleBlas.geev('N', 'N', A.dup(), WR, WI, dummyDouble, dummyDouble);
-                    
-            return new ComplexDoubleMatrix(WR, WI);
-        }
-        
-        /** 
-         * Computes the eigenvalues and eigenvectors of a general matrix.
-         * 
-         * @return an array of ComplexDoubleMatrix objects containing the eigenvectors
-         * stored as the columns of the first matrix, and the eigenvalues as the
-         * diagonal elements of the second matrix.
-         */
-        public static ComplexDoubleMatrix[] eigenvectors(DoubleMatrix A) {
-            A.assertSquare();
-            // setting up result arrays
-            DoubleMatrix WR = new DoubleMatrix(A.rows);
-            DoubleMatrix WI = WR.dup();
-            DoubleMatrix VR = new DoubleMatrix(A.rows, A.rows);
-
-            SimpleBlas.geev('N', 'V', A.dup(), WR, WI, dummyDouble, VR);
-            
-            // transferring the result
-            ComplexDoubleMatrix E = new ComplexDoubleMatrix(WR, WI);
-            ComplexDoubleMatrix V = new ComplexDoubleMatrix(A.rows, A.rows);
-            //System.err.printf("VR = %s\n", VR.toString());
-            for (int i = 0; i < A.rows; i++) {
-                if (E.get(i).isReal()) {
-                    V.putColumn(i, new ComplexDoubleMatrix(VR.getColumn(i)));
-                } else {
-                    ComplexDoubleMatrix v = new ComplexDoubleMatrix(VR.getColumn(i), VR.getColumn(i+1));
-                    V.putColumn(i, v);
-                    V.putColumn(i+1, v.conji());
-                    i += 1;
-                }
-            }
-            return new ComplexDoubleMatrix[] { V, ComplexDoubleMatrix.diag(E) };
-        }
-
-//BEGIN
-  // The code below has been automatically generated.
-  // DO NOT EDIT!
-        private static final FloatMatrix dummyFloat = new FloatMatrix(1);
-    
-        /** Compute the eigenvalues for a symmetric matrix. */
-	public static FloatMatrix symmetricEigenvalues(FloatMatrix A) {
-		A.assertSquare();
-		FloatMatrix eigenvalues = new FloatMatrix(A.rows);
-        int isuppz[] = new int[2*A.rows];
-		SimpleBlas.syevr('N', 'A', 'U', A.dup(), 0, 0, 0, 0, 0, eigenvalues, dummyFloat, isuppz);
-		return eigenvalues;
-	}
-
-        /** 
-         * Computes the eigenvalues and eigenvectors for a symmetric matrix. 
-         *
-         * @return an array of FloatMatrix objects containing the eigenvectors 
-         * stored as the columns of the first matrix, and the eigenvalues as
-         * diagonal elements of the second matrix.
-         */
-	public static FloatMatrix[] symmetricEigenvectors(FloatMatrix A) {
-		A.assertSquare();
-		FloatMatrix eigenvalues = new FloatMatrix(A.rows);
-		FloatMatrix eigenvectors = A.dup();
-        int isuppz[] = new int[2*A.rows];
-        SimpleBlas.syevr('V', 'A', 'U', A.dup(), 0, 0, 0, 0, 0, eigenvalues, eigenvectors, isuppz);
-		return new FloatMatrix[] { eigenvectors, FloatMatrix.diag(eigenvalues) };
-	}
-        
-        /** Computes the eigenvalues of a general matrix. */
-        public static ComplexFloatMatrix eigenvalues(FloatMatrix A) {
-            A.assertSquare();
-            FloatMatrix WR = new FloatMatrix(A.rows);
-            FloatMatrix WI = WR.dup();
-            SimpleBlas.geev('N', 'N', A.dup(), WR, WI, dummyFloat, dummyFloat);
-                    
-            return new ComplexFloatMatrix(WR, WI);
-        }
-        
-        /** 
-         * Computes the eigenvalues and eigenvectors of a general matrix.
-         * 
-         * @return an array of ComplexFloatMatrix objects containing the eigenvectors
-         * stored as the columns of the first matrix, and the eigenvalues as the
-         * diagonal elements of the second matrix.
-         */
-        public static ComplexFloatMatrix[] eigenvectors(FloatMatrix A) {
-            A.assertSquare();
-            // setting up result arrays
-            FloatMatrix WR = new FloatMatrix(A.rows);
-            FloatMatrix WI = WR.dup();
-            FloatMatrix VR = new FloatMatrix(A.rows, A.rows);
-
-            SimpleBlas.geev('N', 'V', A.dup(), WR, WI, dummyFloat, VR);
-            
-            // transferring the result
-            ComplexFloatMatrix E = new ComplexFloatMatrix(WR, WI);
-            ComplexFloatMatrix V = new ComplexFloatMatrix(A.rows, A.rows);
-            //System.err.printf("VR = %s\n", VR.toString());
-            for (int i = 0; i < A.rows; i++) {
-                if (E.get(i).isReal()) {
-                    V.putColumn(i, new ComplexFloatMatrix(VR.getColumn(i)));
-                } else {
-                    ComplexFloatMatrix v = new ComplexFloatMatrix(VR.getColumn(i), VR.getColumn(i+1));
-                    V.putColumn(i, v);
-                    V.putColumn(i+1, v.conji());
-                    i += 1;
-                }
-            }
-            return new ComplexFloatMatrix[] { V, ComplexFloatMatrix.diag(E) };
-        }
-
-//END
-}
diff --git a/src/org/jblas/SimpleBlas.java b/src/org/jblas/SimpleBlas.java
deleted file mode 100644
index d893bf4..0000000
--- a/src/org/jblas/SimpleBlas.java
+++ /dev/null
@@ -1,653 +0,0 @@
-// --- BEGIN LICENSE BLOCK ---
-/* 
- * Copyright (c) 2009, Mikio L. Braun
- * 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.
- */
-// --- END LICENSE BLOCK ---
-
-package org.jblas;
-
-import org.jblas.exceptions.LapackException;
-import org.jblas.exceptions.LapackArgumentException;
-import org.jblas.exceptions.LapackConvergenceException;
-import org.jblas.exceptions.LapackSingularityException;
-
-//import edu.ida.core.OutputValue;
-
-/**
- * This class provides a cleaner direct interface to the BLAS routines by
- * extracting the parameters of the matrices from the matrices itself.
- * 
- * For example, you can just pass the vector and do not have to pass the length,
- * corresponding DoubleBuffer, offset and step size explicitly.
- * 
- * Currently, all the general matrix routines are implemented.
- * 
- */
-public class SimpleBlas {
-	/***************************************************************************
-	 * BLAS Level 1
-	 */
-
-	/** Compute x <-> y (swap two matrices) */
-	public static DoubleMatrix swap(DoubleMatrix x, DoubleMatrix y) {
-		//NativeBlas.dswap(x.length, x.data, 0, 1, y.data, 0, 1);
-		JavaBlas.rswap(x.length, x.data, 0, 1, y.data, 0, 1);
-                return y;
-	}
-
-	/** Compute x <- alpha * x (scale a matrix) */
-	public static DoubleMatrix scal(double alpha, DoubleMatrix x) {
-		NativeBlas.dscal(x.length, alpha, x.data, 0, 1);
-		return x;
-	}
-
-	public static ComplexDoubleMatrix scal(ComplexDouble alpha, ComplexDoubleMatrix x) {
-		NativeBlas.zscal(x.length, alpha, x.data, 0, 1);
-		return x;
-	}
-		
-	/** Compute y <- x (copy a matrix) */
-	public static DoubleMatrix copy(DoubleMatrix x, DoubleMatrix y) {
-		//NativeBlas.dcopy(x.length, x.data, 0, 1, y.data, 0, 1);
-                JavaBlas.rcopy(x.length, x.data, 0, 1, y.data, 0, 1);
-		return y;
-	}
-	
-	public static ComplexDoubleMatrix copy(ComplexDoubleMatrix x, ComplexDoubleMatrix y) {
-		NativeBlas.zcopy(x.length, x.data, 0, 1, y.data, 0, 1);
-		return y;		
-	}
-	
-	/** Compute y <- alpha * x + y (elementwise addition) */
-	public static DoubleMatrix axpy(double da, DoubleMatrix dx, DoubleMatrix dy) {
-		//NativeBlas.daxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
-		JavaBlas.raxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
-             
-		return dy;
-	}
-
-	public static ComplexDoubleMatrix axpy(ComplexDouble da, ComplexDoubleMatrix dx, ComplexDoubleMatrix dy) {
-		NativeBlas.zaxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
-		return dy;
-	}
-
-	/** Compute x^T * y (dot product) */
-	public static double dot(DoubleMatrix x, DoubleMatrix y) {
-		//return NativeBlas.ddot(x.length, x.data, 0, 1, y.data, 0, 1);
-                return JavaBlas.rdot(x.length, x.data, 0, 1, y.data, 0, 1);
-	}
-
-	/** Compute x^T * y (dot product) */
-	public static ComplexDouble dotc(ComplexDoubleMatrix x, ComplexDoubleMatrix y) {
-		return NativeBlas.zdotc(x.length, x.data, 0, 1, y.data, 0, 1);
-	}
-	
-	/** Compute x^T * y (dot product) */
-	public static ComplexDouble dotu(ComplexDoubleMatrix x, ComplexDoubleMatrix y) {
-		return NativeBlas.zdotu(x.length, x.data, 0, 1, y.data, 0, 1);
-	}
-
-	/** Compute || x ||_2 (2-norm) */
-	public static double nrm2(DoubleMatrix x) {
-		return NativeBlas.dnrm2(x.length, x.data, 0, 1);
-	}
-	
-	public static double nrm2(ComplexDoubleMatrix x) {
-		return NativeBlas.dznrm2(x.length, x.data, 0, 1);
-	}
-
-	/** Compute || x ||_1 (1-norm, sum of absolute values) */
-	public static double asum(DoubleMatrix x) {
-		return NativeBlas.dasum(x.length, x.data, 0, 1);
-	}
-
-	public static double asum(ComplexDoubleMatrix x) {
-		return NativeBlas.dzasum(x.length, x.data, 0, 1);
-	}
-
-	/**
-	 * Compute index of element with largest absolute value (index of absolute
-	 * value maximum)
-	 */
-	public static int iamax(DoubleMatrix x) {
-		return NativeBlas.idamax(x.length, x.data, 0, 1) - 1;
-	}
-
-	public static int iamax(ComplexDoubleMatrix x) {
-		return NativeBlas.izamax(x.length, x.data, 0, 1);
-	}
-
-	/***************************************************************************
-	 * BLAS Level 2
-	 */
-
-	/**
-	 * Compute y <- alpha*op(a)*x + beta * y (general matrix vector
-	 * multiplication)
-	 */
-	public static DoubleMatrix gemv(double alpha, DoubleMatrix a,
-			DoubleMatrix x, double beta, DoubleMatrix y) {
-            if (false) {
-		NativeBlas.dgemv('N', a.rows, a.columns, alpha, a.data, 0, a.rows, x.data, 0,
-				1, beta, y.data, 0, 1);
-            }
-            else {
-                if (beta == 0.0) {
-                    for (int i = 0; i < y.length; i++)
-                        y.data[i] = 0.0;
-                    
-                    for (int j = 0; j < a.columns; j++) {
-                        double xj = x.get(j);
-                        if (xj != 0.0) {
-                            for (int i = 0; i < a.rows; i++)
-                                y.data[i] += a.get(i, j) * xj;
-                        }
-                    }
-                }
-                else {
-                     for (int j = 0; j < a.columns; j++) {
-                         double byj = beta * y.data[j];
-                         double xj = x.get(j);
-                         for (int i = 0; i < a.rows; i++)
-                              y.data[j] = a.get(i, j) * xj + byj;
-                     }
-                }
-            }
-	    return y;
-	}
-
-	/** Compute A <- alpha * x * y^T + A (general rank-1 update) */
-	public static DoubleMatrix ger(double alpha, DoubleMatrix x,
-			DoubleMatrix y, DoubleMatrix a) {
-		NativeBlas.dger(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
-				0, a.rows);
-		return a;
-	}
-
-	/** Compute A <- alpha * x * y^T + A (general rank-1 update) */
-	public static ComplexDoubleMatrix geru(ComplexDouble alpha, ComplexDoubleMatrix x,
-			ComplexDoubleMatrix y, ComplexDoubleMatrix a) {
-		NativeBlas.zgeru(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
-				0, a.rows);
-		return a;
-	}
-
-	/** Compute A <- alpha * x * y^H + A (general rank-1 update) */
-	public static ComplexDoubleMatrix gerc(ComplexDouble alpha, ComplexDoubleMatrix x,
-			ComplexDoubleMatrix y, ComplexDoubleMatrix a) {
-		NativeBlas.zgerc(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
-				0, a.rows);
-		return a;
-	}
-
-	/***************************************************************************
-	 * BLAS Level 3
-	 */
-
-	/**
-	 * Compute c <- a*b + beta * c (general matrix matrix
-	 * multiplication)
-	 */
-	public static DoubleMatrix gemm(double alpha, DoubleMatrix a,
-			DoubleMatrix b, double beta, DoubleMatrix c) {
-		NativeBlas.dgemm('N', 'N', c.rows, c.columns, a.columns, alpha, a.data, 0,
-				a.rows, b.data, 0, b.rows, beta, c.data, 0, c.rows);
-		return c;
-	}
-
-	public static ComplexDoubleMatrix gemm(ComplexDouble alpha, ComplexDoubleMatrix a,
-			ComplexDoubleMatrix b, ComplexDouble beta, ComplexDoubleMatrix c) {
-		NativeBlas.zgemm('N', 'N', c.rows, c.columns, a.columns, alpha, a.data, 0,
-				a.rows, b.data, 0, b.rows, beta, c.data, 0, c.rows);
-		return c;
-	}
-
-	/***************************************************************************
-	 * LAPACK
-	 */
-	public static DoubleMatrix gesv(DoubleMatrix a, int[] ipiv,
-			DoubleMatrix b) {
-		int info = NativeBlas.dgesv(a.rows, b.columns, a.data, 0, a.rows, ipiv, 0,
-				b.data, 0, b.rows);
-		checkInfo("DGESV", info);
-
-		if (info > 0)
-			throw new LapackException("DGESV",
-					"Linear equation cannot be solved because the matrix was singular.");
-
-		return b;
-	}
-
-//STOP
-	private static void checkInfo(String name, int info) {
-		if (info < -1)
-			throw new LapackArgumentException(name, info);
-	}
-//START
-
-	public static DoubleMatrix sysv(char uplo, DoubleMatrix a, int[] ipiv,
-			DoubleMatrix b) {
-		int info = NativeBlas.dsysv(uplo, a.rows, b.columns, a.data, 0, a.rows, ipiv, 0,
-				b.data, 0, b.rows);
-		checkInfo("SYSV", info);
-
-		if (info > 0)
-			throw new LapackSingularityException("SYV",
-					"Linear equation cannot be solved because the matrix was singular.");
-
-		return b;
-	}
-
-	public static int syev(char jobz, char uplo, DoubleMatrix a, DoubleMatrix w) {
-		int info = NativeBlas.dsyev(jobz, uplo, a.rows, a.data, 0, a.rows, w.data, 0);
-
-		if (info > 0)
-			throw new LapackConvergenceException("SYEV",
-					"Eigenvalues could not be computed " + info
-							+ " off-diagonal elements did not converge");
-
-		return info;
-	}
-
-	public static int syevx(char jobz, char range, char uplo, DoubleMatrix a,
-			double vl, double vu, int il, int iu, double abstol,
-			DoubleMatrix w, DoubleMatrix z) {
-		int n = a.rows;
-		int[] iwork = new int[5 * n];
-		int[] ifail = new int[n];
-        int[] m = new int[1];
-        int info;
-
-		info = NativeBlas.dsyevx(jobz, range, uplo, n, a.data, 0, a.rows, vl, vu, il,
-				iu, abstol, m, 0, w.data, 0, z.data, 0, z.rows, iwork, 0, ifail, 0);
-
-		if (info > 0) {
-			StringBuilder msg = new StringBuilder();
-			msg
-					.append("Not all eigenvalues converged. Non-converging eigenvalues were: ");
-			for (int i = 0; i < info; i++) {
-				if (i > 0)
-					msg.append(", ");
-				msg.append(ifail[i]);
-			}
-			msg.append(".");
-			throw new LapackConvergenceException("SYEVX", msg.toString());
-		}
-
-		return info;
-	}
-
-	public static int syevd(char jobz, char uplo, DoubleMatrix A,
-			DoubleMatrix w) {
-		int n = A.rows;
-
-		int info = NativeBlas.dsyevd(jobz, uplo, n, A.data, 0, A.rows, w.data, 0);
-
-		if (info > 0)
-			throw new LapackConvergenceException("SYEVD", "Not all eigenvalues converged.");
-
-		return info;
-	}
-
-    public static int syevr(char jobz, char range, char uplo, DoubleMatrix a,
-			double vl, double vu, int il, int iu, double abstol,
-			DoubleMatrix w, DoubleMatrix z, int[] isuppz) {
-		int n = a.rows;
-        int[] m = new int[1];
-
-		int info = NativeBlas.dsyevr(jobz, range, uplo, n, a.data, 0, a.rows, vl, vu,
-                il, iu, abstol, m, 0, w.data, 0, z.data, 0, z.rows, isuppz, 0);
-
-		checkInfo("SYEVR", info);
-
-		return info;
-	}
-
-	public static void posv(char uplo, DoubleMatrix A, DoubleMatrix B) {
-		int n = A.rows;
-		int nrhs = B.columns;
-		int info = NativeBlas.dposv(uplo, n, nrhs, A.data, 0, A.rows, B.data, 0,
-				B.rows);
-		checkInfo("DPOSV", info);
-		if (info > 0)
-			throw new LapackArgumentException("DPOSV",
-					"Leading minor of order i of A is not positive definite.");
-	}
-        
-        public static int geev(char jobvl, char jobvr, DoubleMatrix A, 
-                DoubleMatrix WR, DoubleMatrix WI, DoubleMatrix VL, DoubleMatrix VR) {
-            int info = NativeBlas.dgeev(jobvl, jobvr, A.rows, A.data, 0, A.rows, WR.data, 0,
-                    WI.data, 0, VL.data, 0, VL.rows, VR.data, 0, VR.rows);
-            if (info > 0)
-                throw new LapackConvergenceException("DGEEV", "First " + info + " eigenvalues have not converged.");
-            return info;
-        }
-
-//BEGIN
-  // The code below has been automatically generated.
-  // DO NOT EDIT!
-	/***************************************************************************
-	 * BLAS Level 1
-	 */
-
-	/** Compute x <-> y (swap two matrices) */
-	public static FloatMatrix swap(FloatMatrix x, FloatMatrix y) {
-		//NativeBlas.sswap(x.length, x.data, 0, 1, y.data, 0, 1);
-		JavaBlas.rswap(x.length, x.data, 0, 1, y.data, 0, 1);
-                return y;
-	}
-
-	/** Compute x <- alpha * x (scale a matrix) */
-	public static FloatMatrix scal(float alpha, FloatMatrix x) {
-		NativeBlas.sscal(x.length, alpha, x.data, 0, 1);
-		return x;
-	}
-
-	public static ComplexFloatMatrix scal(ComplexFloat alpha, ComplexFloatMatrix x) {
-		NativeBlas.cscal(x.length, alpha, x.data, 0, 1);
-		return x;
-	}
-		
-	/** Compute y <- x (copy a matrix) */
-	public static FloatMatrix copy(FloatMatrix x, FloatMatrix y) {
-		//NativeBlas.scopy(x.length, x.data, 0, 1, y.data, 0, 1);
-                JavaBlas.rcopy(x.length, x.data, 0, 1, y.data, 0, 1);
-		return y;
-	}
-	
-	public static ComplexFloatMatrix copy(ComplexFloatMatrix x, ComplexFloatMatrix y) {
-		NativeBlas.ccopy(x.length, x.data, 0, 1, y.data, 0, 1);
-		return y;		
-	}
-	
-	/** Compute y <- alpha * x + y (elementwise addition) */
-	public static FloatMatrix axpy(float da, FloatMatrix dx, FloatMatrix dy) {
-		//NativeBlas.saxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
-		JavaBlas.raxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
-             
-		return dy;
-	}
-
-	public static ComplexFloatMatrix axpy(ComplexFloat da, ComplexFloatMatrix dx, ComplexFloatMatrix dy) {
-		NativeBlas.caxpy(dx.length, da, dx.data, 0, 1, dy.data, 0, 1);
-		return dy;
-	}
-
-	/** Compute x^T * y (dot product) */
-	public static float dot(FloatMatrix x, FloatMatrix y) {
-		//return NativeBlas.sdot(x.length, x.data, 0, 1, y.data, 0, 1);
-                return JavaBlas.rdot(x.length, x.data, 0, 1, y.data, 0, 1);
-	}
-
-	/** Compute x^T * y (dot product) */
-	public static ComplexFloat dotc(ComplexFloatMatrix x, ComplexFloatMatrix y) {
-		return NativeBlas.cdotc(x.length, x.data, 0, 1, y.data, 0, 1);
-	}
-	
-	/** Compute x^T * y (dot product) */
-	public static ComplexFloat dotu(ComplexFloatMatrix x, ComplexFloatMatrix y) {
-		return NativeBlas.cdotu(x.length, x.data, 0, 1, y.data, 0, 1);
-	}
-
-	/** Compute || x ||_2 (2-norm) */
-	public static float nrm2(FloatMatrix x) {
-		return NativeBlas.snrm2(x.length, x.data, 0, 1);
-	}
-	
-	public static float nrm2(ComplexFloatMatrix x) {
-		return NativeBlas.scnrm2(x.length, x.data, 0, 1);
-	}
-
-	/** Compute || x ||_1 (1-norm, sum of absolute values) */
-	public static float asum(FloatMatrix x) {
-		return NativeBlas.sasum(x.length, x.data, 0, 1);
-	}
-
-	public static float asum(ComplexFloatMatrix x) {
-		return NativeBlas.scasum(x.length, x.data, 0, 1);
-	}
-
-	/**
-	 * Compute index of element with largest absolute value (index of absolute
-	 * value maximum)
-	 */
-	public static int iamax(FloatMatrix x) {
-		return NativeBlas.isamax(x.length, x.data, 0, 1) - 1;
-	}
-
-	public static int iamax(ComplexFloatMatrix x) {
-		return NativeBlas.icamax(x.length, x.data, 0, 1);
-	}
-
-	/***************************************************************************
-	 * BLAS Level 2
-	 */
-
-	/**
-	 * Compute y <- alpha*op(a)*x + beta * y (general matrix vector
-	 * multiplication)
-	 */
-	public static FloatMatrix gemv(float alpha, FloatMatrix a,
-			FloatMatrix x, float beta, FloatMatrix y) {
-            if (false) {
-		NativeBlas.sgemv('N', a.rows, a.columns, alpha, a.data, 0, a.rows, x.data, 0,
-				1, beta, y.data, 0, 1);
-            }
-            else {
-                if (beta == 0.0f) {
-                    for (int i = 0; i < y.length; i++)
-                        y.data[i] = 0.0f;
-                    
-                    for (int j = 0; j < a.columns; j++) {
-                        float xj = x.get(j);
-                        if (xj != 0.0f) {
-                            for (int i = 0; i < a.rows; i++)
-                                y.data[i] += a.get(i, j) * xj;
-                        }
-                    }
-                }
-                else {
-                     for (int j = 0; j < a.columns; j++) {
-                         float byj = beta * y.data[j];
-                         float xj = x.get(j);
-                         for (int i = 0; i < a.rows; i++)
-                              y.data[j] = a.get(i, j) * xj + byj;
-                     }
-                }
-            }
-	    return y;
-	}
-
-	/** Compute A <- alpha * x * y^T + A (general rank-1 update) */
-	public static FloatMatrix ger(float alpha, FloatMatrix x,
-			FloatMatrix y, FloatMatrix a) {
-		NativeBlas.sger(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
-				0, a.rows);
-		return a;
-	}
-
-	/** Compute A <- alpha * x * y^T + A (general rank-1 update) */
-	public static ComplexFloatMatrix geru(ComplexFloat alpha, ComplexFloatMatrix x,
-			ComplexFloatMatrix y, ComplexFloatMatrix a) {
-		NativeBlas.cgeru(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
-				0, a.rows);
-		return a;
-	}
-
-	/** Compute A <- alpha * x * y^H + A (general rank-1 update) */
-	public static ComplexFloatMatrix gerc(ComplexFloat alpha, ComplexFloatMatrix x,
-			ComplexFloatMatrix y, ComplexFloatMatrix a) {
-		NativeBlas.cgerc(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
-				0, a.rows);
-		return a;
-	}
-
-	/***************************************************************************
-	 * BLAS Level 3
-	 */
-
-	/**
-	 * Compute c <- a*b + beta * c (general matrix matrix
-	 * multiplication)
-	 */
-	public static FloatMatrix gemm(float alpha, FloatMatrix a,
-			FloatMatrix b, float beta, FloatMatrix c) {
-		NativeBlas.sgemm('N', 'N', c.rows, c.columns, a.columns, alpha, a.data, 0,
-				a.rows, b.data, 0, b.rows, beta, c.data, 0, c.rows);
-		return c;
-	}
-
-	public static ComplexFloatMatrix gemm(ComplexFloat alpha, ComplexFloatMatrix a,
-			ComplexFloatMatrix b, ComplexFloat beta, ComplexFloatMatrix c) {
-		NativeBlas.cgemm('N', 'N', c.rows, c.columns, a.columns, alpha, a.data, 0,
-				a.rows, b.data, 0, b.rows, beta, c.data, 0, c.rows);
-		return c;
-	}
-
-	/***************************************************************************
-	 * LAPACK
-	 */
-	public static FloatMatrix gesv(FloatMatrix a, int[] ipiv,
-			FloatMatrix b) {
-		int info = NativeBlas.sgesv(a.rows, b.columns, a.data, 0, a.rows, ipiv, 0,
-				b.data, 0, b.rows);
-		checkInfo("DGESV", info);
-
-		if (info > 0)
-			throw new LapackException("DGESV",
-					"Linear equation cannot be solved because the matrix was singular.");
-
-		return b;
-	}
-
-
-	public static FloatMatrix sysv(char uplo, FloatMatrix a, int[] ipiv,
-			FloatMatrix b) {
-		int info = NativeBlas.ssysv(uplo, a.rows, b.columns, a.data, 0, a.rows, ipiv, 0,
-				b.data, 0, b.rows);
-		checkInfo("SYSV", info);
-
-		if (info > 0)
-			throw new LapackSingularityException("SYV",
-					"Linear equation cannot be solved because the matrix was singular.");
-
-		return b;
-	}
-
-	public static int syev(char jobz, char uplo, FloatMatrix a, FloatMatrix w) {
-		int info = NativeBlas.ssyev(jobz, uplo, a.rows, a.data, 0, a.rows, w.data, 0);
-
-		if (info > 0)
-			throw new LapackConvergenceException("SYEV",
-					"Eigenvalues could not be computed " + info
-							+ " off-diagonal elements did not converge");
-
-		return info;
-	}
-
-	public static int syevx(char jobz, char range, char uplo, FloatMatrix a,
-			float vl, float vu, int il, int iu, float abstol,
-			FloatMatrix w, FloatMatrix z) {
-		int n = a.rows;
-		int[] iwork = new int[5 * n];
-		int[] ifail = new int[n];
-        int[] m = new int[1];
-        int info;
-
-		info = NativeBlas.ssyevx(jobz, range, uplo, n, a.data, 0, a.rows, vl, vu, il,
-				iu, abstol, m, 0, w.data, 0, z.data, 0, z.rows, iwork, 0, ifail, 0);
-
-		if (info > 0) {
-			StringBuilder msg = new StringBuilder();
-			msg
-					.append("Not all eigenvalues converged. Non-converging eigenvalues were: ");
-			for (int i = 0; i < info; i++) {
-				if (i > 0)
-					msg.append(", ");
-				msg.append(ifail[i]);
-			}
-			msg.append(".");
-			throw new LapackConvergenceException("SYEVX", msg.toString());
-		}
-
-		return info;
-	}
-
-	public static int syevd(char jobz, char uplo, FloatMatrix A,
-			FloatMatrix w) {
-		int n = A.rows;
-
-		int info = NativeBlas.ssyevd(jobz, uplo, n, A.data, 0, A.rows, w.data, 0);
-
-		if (info > 0)
-			throw new LapackConvergenceException("SYEVD", "Not all eigenvalues converged.");
-
-		return info;
-	}
-
-    public static int syevr(char jobz, char range, char uplo, FloatMatrix a,
-			float vl, float vu, int il, int iu, float abstol,
-			FloatMatrix w, FloatMatrix z, int[] isuppz) {
-		int n = a.rows;
-        int[] m = new int[1];
-
-		int info = NativeBlas.ssyevr(jobz, range, uplo, n, a.data, 0, a.rows, vl, vu,
-                il, iu, abstol, m, 0, w.data, 0, z.data, 0, z.rows, isuppz, 0);
-
-		checkInfo("SYEVR", info);
-
-		return info;
-	}
-
-	public static void posv(char uplo, FloatMatrix A, FloatMatrix B) {
-		int n = A.rows;
-		int nrhs = B.columns;
-		int info = NativeBlas.sposv(uplo, n, nrhs, A.data, 0, A.rows, B.data, 0,
-				B.rows);
-		checkInfo("DPOSV", info);
-		if (info > 0)
-			throw new LapackArgumentException("DPOSV",
-					"Leading minor of order i of A is not positive definite.");
-	}
-        
-        public static int geev(char jobvl, char jobvr, FloatMatrix A, 
-                FloatMatrix WR, FloatMatrix WI, FloatMatrix VL, FloatMatrix VR) {
-            int info = NativeBlas.sgeev(jobvl, jobvr, A.rows, A.data, 0, A.rows, WR.data, 0,
-                    WI.data, 0, VL.data, 0, VL.rows, VR.data, 0, VR.rows);
-            if (info > 0)
-                throw new LapackConvergenceException("DGEEV", "First " + info + " eigenvalues have not converged.");
-            return info;
-        }
-
-//END
-}
diff --git a/test/org/jblas/ComplexDoubleMatrixTest.java b/src/test/java/org/jblas/ComplexDoubleMatrixTest.java
similarity index 100%
rename from test/org/jblas/ComplexDoubleMatrixTest.java
rename to src/test/java/org/jblas/ComplexDoubleMatrixTest.java
diff --git a/test/org/jblas/SimpleBlasTest.java b/src/test/java/org/jblas/SimpleBlasTest.java
similarity index 100%
rename from test/org/jblas/SimpleBlasTest.java
rename to src/test/java/org/jblas/SimpleBlasTest.java
diff --git a/test/org/jblas/TestBlasDouble.java b/src/test/java/org/jblas/TestBlasDouble.java
similarity index 100%
rename from test/org/jblas/TestBlasDouble.java
rename to src/test/java/org/jblas/TestBlasDouble.java
diff --git a/test/org/jblas/TestBlasDoubleComplex.java b/src/test/java/org/jblas/TestBlasDoubleComplex.java
similarity index 100%
rename from test/org/jblas/TestBlasDoubleComplex.java
rename to src/test/java/org/jblas/TestBlasDoubleComplex.java
diff --git a/test/org/jblas/TestBlasFloat.java b/src/test/java/org/jblas/TestBlasFloat.java
similarity index 100%
rename from test/org/jblas/TestBlasFloat.java
rename to src/test/java/org/jblas/TestBlasFloat.java
diff --git a/test/org/jblas/TestComplexFloat.java b/src/test/java/org/jblas/TestComplexFloat.java
similarity index 100%
rename from test/org/jblas/TestComplexFloat.java
rename to src/test/java/org/jblas/TestComplexFloat.java
diff --git a/test/org/jblas/TestDoubleMatrix.java b/src/test/java/org/jblas/TestDoubleMatrix.java
similarity index 100%
copy from test/org/jblas/TestDoubleMatrix.java
copy to src/test/java/org/jblas/TestDoubleMatrix.java
diff --git a/test/org/jblas/TestEigen.java b/src/test/java/org/jblas/TestEigen.java
similarity index 71%
rename from test/org/jblas/TestEigen.java
rename to src/test/java/org/jblas/TestEigen.java
index 7bb425b..5aa7215 100644
--- a/test/org/jblas/TestEigen.java
+++ b/src/test/java/org/jblas/TestEigen.java
@@ -41,27 +41,58 @@
 package org.jblas;
 
 import junit.framework.TestCase;
+import org.jblas.util.Logger;
 
 /**
- *
+ * Test Class for org.jblas.Eigen
+ * 
  * @author mikio
  */
 public class TestEigen extends TestCase {
 
     public TestEigen(String testName) {
         super(testName);
+        Logger.getLogger().setLevel(Logger.DEBUG);
     }
 
     public void testEigenvalues() {
         DoubleMatrix A = new DoubleMatrix(2, 2, 3.0, -3.0, 1.0, 1.0);
 
         ComplexDoubleMatrix E = Eigen.eigenvalues(A);
-        
+
         //System.out.printf("E = %s\n", E.toString());
-        
+
         ComplexDoubleMatrix[] EV = Eigen.eigenvectors(A);
-        
+
         //System.out.printf("values = %s\n", EV[1].toString());
         //System.out.printf("vectors = %s\n", EV[0].toString());
     }
+
+    public void testSymmetricEigenvalues() {
+        DoubleMatrix A = new DoubleMatrix(new double[][]{
+                {3.0, 1.0, 0.5},
+                {1.0, 3.0, 1.0},
+                {0.5, 1.0, 3.0}
+        });
+
+        DoubleMatrix B = new DoubleMatrix(new double[][]{
+                {2.0, 0.1, 0.0},
+                {0.1, 2.0, 0.1},
+                {0.0, 0.1, 2.0}
+        });
+
+        DoubleMatrix[] results = Eigen.symmetricGeneralizedEigenvectors(A, B);
+
+        DoubleMatrix V = results[0];
+        DoubleMatrix L = results[1];
+
+        DoubleMatrix LHS = A.mmul(V);
+        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);
+    }
 }
diff --git a/test/org/jblas/TestDoubleMatrix.java b/src/test/java/org/jblas/TestFloatMatrix.java
similarity index 61%
rename from test/org/jblas/TestDoubleMatrix.java
rename to src/test/java/org/jblas/TestFloatMatrix.java
index b3f5a49..c669188 100644
--- a/test/org/jblas/TestDoubleMatrix.java
+++ b/src/test/java/org/jblas/TestFloatMatrix.java
@@ -42,21 +42,21 @@ import junit.framework.TestCase;
 import java.util.Arrays;
 import static org.jblas.ranges.RangeUtils.*;
 
-public class TestDoubleMatrix extends TestCase {
+public class TestFloatMatrix extends TestCase {
 
-    DoubleMatrix A, B, C, D, E, F;
+    FloatMatrix A, B, C, D, E, F;
 
     public void setUp() {
-        A = new DoubleMatrix(4, 3, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0);
-        B = new DoubleMatrix(3, 1, 2.0, 4.0, 8.0);
-        C = new DoubleMatrix(3, 1, -1.0, 2.0, -3.0);
-        D = new DoubleMatrix(3, 3, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
-        E = new DoubleMatrix(3, 3, 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0, 9.0);
-        F = new DoubleMatrix(3, 1, 3.0, 4.0, 7.0);
+        A = new FloatMatrix(4, 3, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f);
+        B = new FloatMatrix(3, 1, 2.0f, 4.0f, 8.0f);
+        C = new FloatMatrix(3, 1, -1.0f, 2.0f, -3.0f);
+        D = new FloatMatrix(3, 3, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f);
+        E = new FloatMatrix(3, 3, 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f, 9.0f);
+        F = new FloatMatrix(3, 1, 3.0f, 4.0f, 7.0f);
     }
 
     public void testConstructionAndSetGet() {
-        double[][] dataA = {{1.0, 5.0, 9.0}, {2.0, 6.0, 10.0}, {3.0, 7.0, 11.0}, {4.0, 8.0, 12.0}};
+        float[][] dataA = {{1.0f, 5.0f, 9.0f}, {2.0f, 6.0f, 10.0f}, {3.0f, 7.0f, 11.0f}, {4.0f, 8.0f, 12.0f}};
 
         assertEquals(A.rows, 4);
         assertEquals(A.columns, 3);
@@ -69,7 +69,7 @@ public class TestDoubleMatrix extends TestCase {
     }
 
     public void testSetAndGet() {
-        DoubleMatrix M = new DoubleMatrix(3, 3);
+        FloatMatrix M = new FloatMatrix(3, 3);
 
         for (int i = 0; i < 3; i++) {
             for (int j = 0; j < 3; j++) {
@@ -78,13 +78,13 @@ public class TestDoubleMatrix extends TestCase {
         }
         for (int i = 0; i < 3; i++) {
             for (int j = 0; j < 3; j++) {
-                assertEquals((double) i + j, M.get(i, j));
+                assertEquals((float) i + j, M.get(i, j));
             }
         }
     }
 
     public void testCopy() {
-        DoubleMatrix M = new DoubleMatrix();
+        FloatMatrix M = new FloatMatrix();
 
         assertFalse(M.equals(A));
 
@@ -93,15 +93,15 @@ public class TestDoubleMatrix extends TestCase {
     }
 
     public void testDup() {
-        DoubleMatrix M = A.dup();
+        FloatMatrix M = A.dup();
         assertEquals(M, A);
 
-        M.put(0, 0, 2.0);
+        M.put(0, 0, 2.0f);
         assertFalse(M.equals(A));
     }
 
     public void testResize() {
-        DoubleMatrix M = A.dup();
+        FloatMatrix M = A.dup();
 
         assertEquals(4, M.rows);
         assertEquals(3, M.columns);
@@ -110,31 +110,31 @@ public class TestDoubleMatrix extends TestCase {
         assertEquals(4, M.rows);
         assertEquals(5, M.columns);
 
-        assertEquals(0.0, M.get(3, 4));
+        assertEquals(0.0f, M.get(3, 4));
     }
 
     public void testReshape() {
-        DoubleMatrix M = new DoubleMatrix(2, 2, 1.0, 2.0, 3.0, 4.0);
+        FloatMatrix M = new FloatMatrix(2, 2, 1.0f, 2.0f, 3.0f, 4.0f);
 
         M.reshape(1, 4);
-        assertEquals(1.0, M.get(0, 0));
-        assertEquals(4.0, M.get(0, 3));
+        assertEquals(1.0f, M.get(0, 0));
+        assertEquals(4.0f, M.get(0, 3));
 
         M.reshape(4, 1);
-        assertEquals(1.0, M.get(0, 0));
-        assertEquals(4.0, M.get(3, 0));
+        assertEquals(1.0f, M.get(0, 0));
+        assertEquals(4.0f, M.get(3, 0));
     }
 
     public void testMmul() {
-        DoubleMatrix R = A.dup();
-        DoubleMatrix result = new DoubleMatrix(4, 1, 94.0, 108.0, 122.0, 136.0);
+        FloatMatrix R = A.dup();
+        FloatMatrix result = new FloatMatrix(4, 1, 94.0f, 108.0f, 122.0f, 136.0f);
 
         A.mmuli(B, R);
         assertEquals(result, R);
 
         assertEquals(result, A.mmul(B));
 
-        DoubleMatrix resultDE = new DoubleMatrix(3, 3, 14.0, 16.0, 18.0, -26.0, -31.0, -36.0, 38.0, 46.0, 54.0);
+        FloatMatrix resultDE = new FloatMatrix(3, 3, 14.0f, 16.0f, 18.0f, -26.0f, -31.0f, -36.0f, 38.0f, 46.0f, 54.0f);
 
         // In-place with independent operands
         assertEquals(resultDE, D.mmuli(E, R));
@@ -152,9 +152,9 @@ public class TestDoubleMatrix extends TestCase {
     }
 
     public void testAdd() {
-        DoubleMatrix result = new DoubleMatrix(3, 1, 1.0, 6.0, 5.0);
+        FloatMatrix result = new FloatMatrix(3, 1, 1.0f, 6.0f, 5.0f);
 
-        DoubleMatrix R = new DoubleMatrix();
+        FloatMatrix R = new FloatMatrix();
 
         // In-place, but independent operands
         B.addi(C, R);
@@ -171,23 +171,23 @@ public class TestDoubleMatrix extends TestCase {
         // fully dynamic
         assertEquals(result, B.add(C));
 
-        result = new DoubleMatrix(3, 1, 3.0, 5.0, 9.0);
+        result = new FloatMatrix(3, 1, 3.0f, 5.0f, 9.0f);
 
         // In-place, but independent operands
-        assertEquals(result, B.addi(1.0, R));
+        assertEquals(result, B.addi(1.0f, R));
 
         // In-place on this
         R = B.dup();
-        assertEquals(result, R.addi(1.0, R));
+        assertEquals(result, R.addi(1.0f, R));
 
         // fully dynamic
-        assertEquals(result, B.add(1.0));
+        assertEquals(result, B.add(1.0f));
     }
 
     public void testSub() {
-        DoubleMatrix result = new DoubleMatrix(3, 1, 3.0, 2.0, 11.0);
+        FloatMatrix result = new FloatMatrix(3, 1, 3.0f, 2.0f, 11.0f);
 
-        DoubleMatrix R = new DoubleMatrix();
+        FloatMatrix R = new FloatMatrix();
 
         // In-place, but independent operands
         assertEquals(result, B.subi(C, R));
@@ -203,23 +203,23 @@ public class TestDoubleMatrix extends TestCase {
         // fully dynamic
         assertEquals(result, B.sub(C));
 
-        result = new DoubleMatrix(3, 1, 1.0, 3.0, 7.0);
+        result = new FloatMatrix(3, 1, 1.0f, 3.0f, 7.0f);
 
         // In-place, but independent operands
-        assertEquals(result, B.subi(1.0, R));
+        assertEquals(result, B.subi(1.0f, R));
 
         // In-place on this
         R = B.dup();
-        assertEquals(result, R.subi(1.0, R));
+        assertEquals(result, R.subi(1.0f, R));
 
         // fully dynamic
-        assertEquals(result, B.sub(1.0));
+        assertEquals(result, B.sub(1.0f));
     }
 
     public void testRsub() {
-        DoubleMatrix result = new DoubleMatrix(3, 1, 3.0, 2.0, 11.0);
+        FloatMatrix result = new FloatMatrix(3, 1, 3.0f, 2.0f, 11.0f);
 
-        DoubleMatrix R = new DoubleMatrix();
+        FloatMatrix R = new FloatMatrix();
 
         // In-place, but independent operands
         assertEquals(result, C.rsubi(B, R));
@@ -235,23 +235,23 @@ public class TestDoubleMatrix extends TestCase {
         // fully dynamic
         assertEquals(result, C.rsub(B));
 
-        result = new DoubleMatrix(3, 1, -1.0, -3.0, -7.0);
+        result = new FloatMatrix(3, 1, -1.0f, -3.0f, -7.0f);
 
         // In-place, but independent operands
-        assertEquals(result, B.rsubi(1.0, R));
+        assertEquals(result, B.rsubi(1.0f, R));
 
         // In-place on this
         R = B.dup();
-        assertEquals(result, R.rsubi(1.0, R));
+        assertEquals(result, R.rsubi(1.0f, R));
 
         // fully dynamic
-        assertEquals(result, B.rsub(1.0));
+        assertEquals(result, B.rsub(1.0f));
     }
 
     public void testMul() {
-        DoubleMatrix result = new DoubleMatrix(3, 1, -2.0, 8.0, -24.0);
+        FloatMatrix result = new FloatMatrix(3, 1, -2.0f, 8.0f, -24.0f);
 
-        DoubleMatrix R = new DoubleMatrix();
+        FloatMatrix R = new FloatMatrix();
 
         // In-place, but independent operands
         assertEquals(result, B.muli(C, R));
@@ -267,23 +267,23 @@ public class TestDoubleMatrix extends TestCase {
         // fully dynamic
         assertEquals(result, B.mul(C));
 
-        result = new DoubleMatrix(3, 1, 1.0, 2.0, 4.0);
+        result = new FloatMatrix(3, 1, 1.0f, 2.0f, 4.0f);
 
         // In-place, but independent operands
-        assertEquals(result, B.muli(0.5, R));
+        assertEquals(result, B.muli(0.5f, R));
 
         // In-place on this
         R = B.dup();
-        assertEquals(result, R.muli(0.5, R));
+        assertEquals(result, R.muli(0.5f, R));
 
         // fully dynamic
-        assertEquals(result, B.mul(0.5));
+        assertEquals(result, B.mul(0.5f));
     }
 
     public void testDiv() {
-        DoubleMatrix result = new DoubleMatrix(3, 1, -2.0, 2.0, -2.666666666);
+        FloatMatrix result = new FloatMatrix(3, 1, -2.0f, 2.0f, -2.666666666f);
 
-        DoubleMatrix R = new DoubleMatrix();
+        FloatMatrix R = new FloatMatrix();
 
         // In-place, but independent operands
         assertEquals(result, B.divi(C, R));
@@ -299,23 +299,23 @@ public class TestDoubleMatrix extends TestCase {
         // fully dynamic
         assertEquals(result, B.div(C));
 
-        result = new DoubleMatrix(3, 1, 1.0, 2.0, 4.0);
+        result = new FloatMatrix(3, 1, 1.0f, 2.0f, 4.0f);
 
         // In-place, but independent operands
-        assertEquals(result, B.divi(2.0, R));
+        assertEquals(result, B.divi(2.0f, R));
 
         // In-place on this
         R = B.dup();
-        assertEquals(result, R.divi(2.0, R));
+        assertEquals(result, R.divi(2.0f, R));
 
         // fully dynamic
-        assertEquals(result, B.div(2.0));
+        assertEquals(result, B.div(2.0f));
     }
 
     public void testRdiv() {
-        DoubleMatrix result = new DoubleMatrix(3, 1, -2.0, 2.0, -2.666666666);
+        FloatMatrix result = new FloatMatrix(3, 1, -2.0f, 2.0f, -2.666666666f);
 
-        DoubleMatrix R = new DoubleMatrix();
+        FloatMatrix R = new FloatMatrix();
 
         // In-place, but independent operands
         assertEquals(result, C.rdivi(B, R));
@@ -331,24 +331,24 @@ public class TestDoubleMatrix extends TestCase {
         // fully dynamic
         assertEquals(result, C.rdiv(B));
 
-        result = new DoubleMatrix(3, 1, 0.5, 0.25, 0.125);
+        result = new FloatMatrix(3, 1, 0.5f, 0.25f, 0.125f);
 
         // In-place, but independent operands
-        assertEquals(result, B.rdivi(1.0, R));
+        assertEquals(result, B.rdivi(1.0f, R));
 
         // In-place on this
         R = B.dup();
-        assertEquals(result, R.rdivi(1.0, R));
+        assertEquals(result, R.rdivi(1.0f, R));
 
         // fully dynamic
-        assertEquals(result, B.rdiv(1.0));
+        assertEquals(result, B.rdiv(1.0f));
     }
 
     /*# def test_logical(op, result, scalar, result2); <<-EOS
     public void test#{op.upcase}() {
-    DoubleMatrix result = new DoubleMatrix(3, 1, #{result});
-    DoubleMatrix result2 = new DoubleMatrix(3, 1, #{result2});
-    DoubleMatrix R = new DoubleMatrix();
+    FloatMatrix result = new FloatMatrix(3, 1, #{result});
+    FloatMatrix result2 = new FloatMatrix(3, 1, #{result2});
+    FloatMatrix R = new FloatMatrix();
     
     // in-place but independent operands
     assertEquals(result, B.#{op}i(F, R));
@@ -374,12 +374,12 @@ public class TestDoubleMatrix extends TestCase {
     EOS
     end	
     #*/
-    /*# test_logical('lt', '1.0, 0.0, 0.0', 4.0, '1.0, 0.0, 0.0') #*/
+    /*# test_logical('lt', '1.0f, 0.0f, 0.0f', 4.0f, '1.0f, 0.0f, 0.0f') #*/
 //RJPP-BEGIN------------------------------------------------------------
     public void testLT() {
-    DoubleMatrix result = new DoubleMatrix(3, 1, 1.0, 0.0, 0.0);
-    DoubleMatrix result2 = new DoubleMatrix(3, 1, 1.0, 0.0, 0.0);
-    DoubleMatrix R = new DoubleMatrix();
+    FloatMatrix result = new FloatMatrix(3, 1, 1.0f, 0.0f, 0.0f);
+    FloatMatrix result2 = new FloatMatrix(3, 1, 1.0f, 0.0f, 0.0f);
+    FloatMatrix R = new FloatMatrix();
     
     // in-place but independent operands
     assertEquals(result, B.lti(F, R));
@@ -397,18 +397,18 @@ public class TestDoubleMatrix extends TestCase {
     
     // in-place in this
     R = B.dup();
-    assertEquals(result2, R.lti(4.0, R));
+    assertEquals(result2, R.lti(4.0f, R));
     
     // fully dynamic
-    assertEquals(result2, B.lt(4.0));	
+    assertEquals(result2, B.lt(4.0f));	
     }
 //RJPP-END--------------------------------------------------------------
-	/*# test_logical('le', '1.0, 1.0, 0.0', 4.0, '1.0, 1.0, 0.0') #*/
+	/*# test_logical('le', '1.0f, 1.0f, 0.0f', 4.0f, '1.0f, 1.0f, 0.0f') #*/
 //RJPP-BEGIN------------------------------------------------------------
     public void testLE() {
-    DoubleMatrix result = new DoubleMatrix(3, 1, 1.0, 1.0, 0.0);
-    DoubleMatrix result2 = new DoubleMatrix(3, 1, 1.0, 1.0, 0.0);
-    DoubleMatrix R = new DoubleMatrix();
+    FloatMatrix result = new FloatMatrix(3, 1, 1.0f, 1.0f, 0.0f);
+    FloatMatrix result2 = new FloatMatrix(3, 1, 1.0f, 1.0f, 0.0f);
+    FloatMatrix R = new FloatMatrix();
     
     // in-place but independent operands
     assertEquals(result, B.lei(F, R));
@@ -426,18 +426,18 @@ public class TestDoubleMatrix extends TestCase {
     
     // in-place in this
     R = B.dup();
-    assertEquals(result2, R.lei(4.0, R));
+    assertEquals(result2, R.lei(4.0f, R));
     
     // fully dynamic
-    assertEquals(result2, B.le(4.0));	
+    assertEquals(result2, B.le(4.0f));	
     }
 //RJPP-END--------------------------------------------------------------
-	/*# test_logical('gt', '0.0, 0.0, 1.0', 4.0, '0.0, 0.0, 1.0') #*/
+	/*# test_logical('gt', '0.0f, 0.0f, 1.0f', 4.0f, '0.0f, 0.0f, 1.0f') #*/
 //RJPP-BEGIN------------------------------------------------------------
     public void testGT() {
-    DoubleMatrix result = new DoubleMatrix(3, 1, 0.0, 0.0, 1.0);
-    DoubleMatrix result2 = new DoubleMatrix(3, 1, 0.0, 0.0, 1.0);
-    DoubleMatrix R = new DoubleMatrix();
+    FloatMatrix result = new FloatMatrix(3, 1, 0.0f, 0.0f, 1.0f);
+    FloatMatrix result2 = new FloatMatrix(3, 1, 0.0f, 0.0f, 1.0f);
+    FloatMatrix R = new FloatMatrix();
     
     // in-place but independent operands
     assertEquals(result, B.gti(F, R));
@@ -455,18 +455,18 @@ public class TestDoubleMatrix extends TestCase {
     
     // in-place in this
     R = B.dup();
-    assertEquals(result2, R.gti(4.0, R));
+    assertEquals(result2, R.gti(4.0f, R));
     
     // fully dynamic
-    assertEquals(result2, B.gt(4.0));	
+    assertEquals(result2, B.gt(4.0f));	
     }
 //RJPP-END--------------------------------------------------------------
-	/*# test_logical('ge', '0.0, 1.0, 1.0', 4.0, '0.0, 1.0, 1.0') #*/
+	/*# test_logical('ge', '0.0f, 1.0f, 1.0f', 4.0f, '0.0f, 1.0f, 1.0f') #*/
 //RJPP-BEGIN------------------------------------------------------------
     public void testGE() {
-    DoubleMatrix result = new DoubleMatrix(3, 1, 0.0, 1.0, 1.0);
-    DoubleMatrix result2 = new DoubleMatrix(3, 1, 0.0, 1.0, 1.0);
-    DoubleMatrix R = new DoubleMatrix();
+    FloatMatrix result = new FloatMatrix(3, 1, 0.0f, 1.0f, 1.0f);
+    FloatMatrix result2 = new FloatMatrix(3, 1, 0.0f, 1.0f, 1.0f);
+    FloatMatrix R = new FloatMatrix();
     
     // in-place but independent operands
     assertEquals(result, B.gei(F, R));
@@ -484,15 +484,15 @@ public class TestDoubleMatrix extends TestCase {
     
     // in-place in this
     R = B.dup();
-    assertEquals(result2, R.gei(4.0, R));
+    assertEquals(result2, R.gei(4.0f, R));
     
     // fully dynamic
-    assertEquals(result2, B.ge(4.0));	
+    assertEquals(result2, B.ge(4.0f));	
     }
 //RJPP-END--------------------------------------------------------------
     public void testMinMax() {
-        assertEquals(1.0, A.min());
-        assertEquals(12.0, A.max());
+        assertEquals(1.0f, A.min());
+        assertEquals(12.0f, A.max());
     }
 
     public void testArgMinMax() {
@@ -501,10 +501,10 @@ public class TestDoubleMatrix extends TestCase {
     }
 
     public void testTranspose() {
-        DoubleMatrix At = A.transpose();
-        assertEquals(1.0, At.get(0, 0));
-        assertEquals(2.0, At.get(0, 1));
-        assertEquals(5.0, At.get(1, 0));
+        FloatMatrix At = A.transpose();
+        assertEquals(1.0f, At.get(0, 0));
+        assertEquals(2.0f, At.get(0, 1));
+        assertEquals(5.0f, At.get(1, 0));
     }
 
     public void testGetRowVector() {
@@ -516,58 +516,58 @@ public class TestDoubleMatrix extends TestCase {
             A.getColumn(c);
         }
 
-        A.addiRowVector(new DoubleMatrix(3, 1, 10.0, 100.0, 1000.0));
-        A.addiColumnVector(new DoubleMatrix(1, 4, 10.0, 100.0, 1000.0, 10000.0));
+        A.addiRowVector(new FloatMatrix(3, 1, 10.0f, 100.0f, 1000.0f));
+        A.addiColumnVector(new FloatMatrix(1, 4, 10.0f, 100.0f, 1000.0f, 10000.0f));
     }
 
     public void testPairwiseDistance() {
-        DoubleMatrix D = Geometry.pairwiseSquaredDistances(A, A);
+        FloatMatrix D = Geometry.pairwiseSquaredDistances(A, A);
 
-        DoubleMatrix X = new DoubleMatrix(1, 3, 1.0, 0.0, -1.0);
+        FloatMatrix X = new FloatMatrix(1, 3, 1.0f, 0.0f, -1.0f);
 
         Geometry.pairwiseSquaredDistances(X, X);
 
-        DoubleMatrix A1 = new DoubleMatrix(1, 2, 1.0, 2.0);
-        DoubleMatrix A2 = new DoubleMatrix(1, 3, 1.0, 2.0, 3.0);
+        FloatMatrix A1 = new FloatMatrix(1, 2, 1.0f, 2.0f);
+        FloatMatrix A2 = new FloatMatrix(1, 3, 1.0f, 2.0f, 3.0f);
 
         Geometry.pairwiseSquaredDistances(A1, A2);
     }
 
     public void testSwapColumns() {
-        DoubleMatrix AA = A.dup();
+        FloatMatrix AA = A.dup();
 
         AA.swapColumns(1, 2);
-        assertEquals(new DoubleMatrix(4, 3, 1.0, 2.0, 3.0, 4.0, 9.0, 10.0, 11.0, 12.0, 5.0, 6.0, 7.0, 8.0), AA);
+        assertEquals(new FloatMatrix(4, 3, 1.0f, 2.0f, 3.0f, 4.0f, 9.0f, 10.0f, 11.0f, 12.0f, 5.0f, 6.0f, 7.0f, 8.0f), AA);
     }
 
     public void testSwapRows() {
-        DoubleMatrix AA = A.dup();
+        FloatMatrix AA = A.dup();
 
         AA.swapRows(1, 2);
-        assertEquals(new DoubleMatrix(4, 3, 1.0, 3.0, 2.0, 4.0, 5.0, 7.0, 6.0, 8.0, 9.0, 11.0, 10.0, 12.0), AA);
+        assertEquals(new FloatMatrix(4, 3, 1.0f, 3.0f, 2.0f, 4.0f, 5.0f, 7.0f, 6.0f, 8.0f, 9.0f, 11.0f, 10.0f, 12.0f), AA);
     }
 
     public void testSolve() {
-        DoubleMatrix AA = new DoubleMatrix(3, 3, 3.0, 5.0, 6.0, 1.0, 0.0, 0.0, 2.0, 4.0, 0.0);
-        DoubleMatrix BB = new DoubleMatrix(3, 1, 1.0, 2.0, 3.0);
+        FloatMatrix AA = new FloatMatrix(3, 3, 3.0f, 5.0f, 6.0f, 1.0f, 0.0f, 0.0f, 2.0f, 4.0f, 0.0f);
+        FloatMatrix BB = new FloatMatrix(3, 1, 1.0f, 2.0f, 3.0f);
 
-        DoubleMatrix Adup = AA.dup();
-        DoubleMatrix Bdup = BB.dup();
+        FloatMatrix Adup = AA.dup();
+        FloatMatrix Bdup = BB.dup();
 
-        DoubleMatrix X = Solve.solve(AA, BB);
+        FloatMatrix X = Solve.solve(AA, BB);
 
         assertEquals(Adup, AA);
         assertEquals(Bdup, BB);
     }
 
     public void testConstructFromArray() {
-        double[][] data = {
-            {1.0, 2.0, 3.0},
-            {4.0, 5.0, 6.0},
-            {7.0, 8.0, 9.0}
+        float[][] data = {
+            {1.0f, 2.0f, 3.0f},
+            {4.0f, 5.0f, 6.0f},
+            {7.0f, 8.0f, 9.0f}
         };
 
-        DoubleMatrix A = new DoubleMatrix(data);
+        FloatMatrix A = new FloatMatrix(data);
 
         for (int r = 0; r < 3; r++) {
             for (int c = 0; c < 3; c++) {
@@ -577,26 +577,26 @@ public class TestDoubleMatrix extends TestCase {
     }
 
     public void testDiag() {
-        DoubleMatrix A = new DoubleMatrix(new double[][]{
-                    {1.0, 2.0, 3.0},
-                    {4.0, 5.0, 6.0},
-                    {7.0, 8.0, 9.0}
+        FloatMatrix A = new FloatMatrix(new float[][]{
+                    {1.0f, 2.0f, 3.0f},
+                    {4.0f, 5.0f, 6.0f},
+                    {7.0f, 8.0f, 9.0f}
                 });
 
-        assertEquals(new DoubleMatrix(3, 1, 1.0, 5.0, 9.0), A.diag());
+        assertEquals(new FloatMatrix(3, 1, 1.0f, 5.0f, 9.0f), A.diag());
 
-        assertEquals(new DoubleMatrix(new double[][]{
-                    {1.0, 0.0, 0.0},
-                    {0.0, 2.0, 0.0},
-                    {0.0, 0.0, 3.0}
-                }), DoubleMatrix.diag(new DoubleMatrix(3, 1, 1.0, 2.0, 3.0)));
+        assertEquals(new FloatMatrix(new float[][]{
+                    {1.0f, 0.0f, 0.0f},
+                    {0.0f, 2.0f, 0.0f},
+                    {0.0f, 0.0f, 3.0f}
+                }), FloatMatrix.diag(new FloatMatrix(3, 1, 1.0f, 2.0f, 3.0f)));
     }
 
     public void testColumnAndRowMinMax() {
-        assertEquals(new DoubleMatrix(1, 3, 1.0, 5.0, 9.0), A.columnMins());
-        assertEquals(new DoubleMatrix(4, 1, 1.0, 2.0, 3.0, 4.0), A.rowMins());
-        assertEquals(new DoubleMatrix(1, 3, 4.0, 8.0, 12.0), A.columnMaxs());
-        assertEquals(new DoubleMatrix(4, 1, 9.0, 10.0, 11.0, 12.0), A.rowMaxs());
+        assertEquals(new FloatMatrix(1, 3, 1.0f, 5.0f, 9.0f), A.columnMins());
+        assertEquals(new FloatMatrix(4, 1, 1.0f, 2.0f, 3.0f, 4.0f), A.rowMins());
+        assertEquals(new FloatMatrix(1, 3, 4.0f, 8.0f, 12.0f), A.columnMaxs());
+        assertEquals(new FloatMatrix(4, 1, 9.0f, 10.0f, 11.0f, 12.0f), A.rowMaxs());
         int[] i = A.columnArgmins();
         assertEquals(0, i[0]);
         assertEquals(0, i[1]);
@@ -618,7 +618,7 @@ public class TestDoubleMatrix extends TestCase {
     }
 
     public void testToArray() {
-        assertTrue(Arrays.equals(new double[]{2.0, 4.0, 8.0}, B.toArray()));
+        assertTrue(Arrays.equals(new float[]{2.0f, 4.0f, 8.0f}, B.toArray()));
         assertTrue(Arrays.equals(new int[]{2, 4, 8}, B.toIntArray()));
         assertTrue(Arrays.equals(new boolean[]{true, true, true}, B.toBooleanArray()));
     }
@@ -628,12 +628,12 @@ public class TestDoubleMatrix extends TestCase {
             File f = File.createTempFile("jblas-test", "txt");
             f.deleteOnExit();
             PrintStream out = new PrintStream(f);
-            out.println("1.0 2.0 3.0");
-            out.println("4.0 5.0 6.0");
+            out.println("1.0f 2.0f 3.0f");
+            out.println("4.0f 5.0f 6.0f");
             out.close();
 
-            DoubleMatrix result = DoubleMatrix.loadAsciiFile(f.getAbsolutePath());
-            assertEquals(new DoubleMatrix(2, 3, 1.0, 4.0, 2.0, 5.0, 3.0, 6.0), result);
+            FloatMatrix result = FloatMatrix.loadAsciiFile(f.getAbsolutePath());
+            assertEquals(new FloatMatrix(2, 3, 1.0f, 4.0f, 2.0f, 5.0f, 3.0f, 6.0f), result);
         } catch (Exception e) {
             fail("Caught exception " + e);
         }
@@ -642,6 +642,6 @@ public class TestDoubleMatrix extends TestCase {
     public void testRanges() {
         // Hm... Broken?
         //System.out.printf("Ranges: %s\n", A.get(interval(0, 2), interval(0, 1)).toString());
-        //assertEquals(new DoubleMatrix(3, 2, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0), );
+        //assertEquals(new FloatMatrix(3, 2, 1.0f, 2.0f, 3.0f, 5.0f, 6.0f, 7.0f), );
     }
 }
diff --git a/test/org/jblas/TestGeometry.java b/src/test/java/org/jblas/TestGeometry.java
similarity index 100%
rename from test/org/jblas/TestGeometry.java
rename to src/test/java/org/jblas/TestGeometry.java
diff --git a/test/org/jblas/TestSolve.java b/test/org/jblas/TestSolve.java
index 9521863..2d96905 100644
--- a/test/org/jblas/TestSolve.java
+++ b/test/org/jblas/TestSolve.java
@@ -39,15 +39,15 @@ package org.jblas;
 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());
+        }
+    }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jblas.git



More information about the pkg-java-commits mailing list