This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Class: NativeInterfaceTest | |
* Method: dgemv_critical_ | |
* Signature: ([C[I[I[D[D[I[D[I[D[D[I)V | |
*/ | |
JNIEXPORT void JNICALL Java_NativeInterfaceTestLAPACK_dgemv_1critical_1 (j<type> foo, ...) | |
{ | |
j<type> foo; | |
#define MACRO_criticalGetPointer(var)\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcc -cpp -O3 -fPIC -o <lib name>.so -shared -Wl,-soname,<lib name>.so -I . -I ${JAVAROOT}/include/ -I ${JAVAROOT}/include/linux/ <file name>.c -l<BLAS lib name> -l<LAPACK lib name> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static { | |
try { | |
System.loadLibrary("<lib name>"); // no "lib" prefix or ".so" suffix | |
} catch (UnsatisfiedLinkError e) { | |
System.err.println("Cannot find <lib name> hooks.\n" + e); | |
System.exit(1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// interface for LAPACK via JNA | |
public interface LAPACKLibrary extends Library { | |
LAPACKLibrary INSTANCE = (LAPACKLibrary) | |
Native.loadLibrary("liblapack.so",LAPACKLibrary.class); | |
LAPACKLibrary SYNC_INSTANCE = (LAPACKLibrary) Native.synchronizedLibrary(INSTANCE); | |
void dgemv_(...); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DGEMV_F77 F77_FUNC(dgemv,DGEMV) | |
#ifdef __cplusplus | |
extern "C" | |
#endif | |
void DGEMV_F77(char* trans, int* m, int* n, double* alpha, double* a, int* lda, double* x, int* incx, double* beta, double* y, int* incy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __cplusplus | |
extern "C" | |
#endif | |
/* | |
* Class: OGBLASRawWrapper | |
* Method: wrapped_dgemv | |
* Signature: (CIID[DI[DID[DI)V | |
*/ | |
JNIEXPORT void JNICALL Java_com_opengamma_maths_nativewrappers_OGBLASRawWrapper_wrapped_1dgemv(JNIEnv * env, jclass theClass, jchar trans, jint m, jint n, jdouble alpha, jdoubleArray a, jint _offset_a ,jint lda, jdoubleArray x, jint _offset_x ,jint incx, jdouble beta, jdoubleArray y, jint _offset_y ,jint incy) { | |
char* _OG_ctrans = (char*) &trans; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void dgemv(char trans, int m, int n, double alpha, double[] a, int _offset_a, int lda, double[] x, int _offset_x, int incx, double beta, double[] y, int _offset_y, int incy) | |
{ | |
#ifdef THREAD_SAFETY_ENTRY_PT | |
#include THREAD_SAFETY_ENTRY_PT_CODE | |
#endif | |
wrapped_dgemv(trans, m, n, alpha, a, _offset_a, lda, x, _offset_x, incx, beta, y, _offset_y, incy); | |
#ifdef THREAD_SAFETY_EXIT_PT | |
#include THREAD_SAFETY_EXIT_PT_CODE | |
#endif | |
#ifdef ERROR_HANDLER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static native void wrapped_dgemv(char trans, int m, int n, double alpha, double[] a, int _offset_a, int lda, double[] x, int _offset_x, int incx, double beta, double[] y, int _offset_y, int incy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// implement fortran xerbla | |
#define XERBLA_F77 F77_FUNC(xerbla,XERBLA) | |
// global cache of the VM ptr | |
JavaVM *JVMcache; | |
// Called when the native library is loaded | |
#ifdef __cplusplus | |
extern "C" | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% A translation of http://commons.apache.org/math/userguide/linear.html Example in section 3.2 | |
%% Apache Commons Math is refered to as ACM | |
clear all; close all; clc; | |
% assume the jars in in the pwd, add to java class path | |
javaaddpath([pwd,'/commons-math3-3.0.jar']); | |
javaaddpath([pwd,'/octave.jar']); | |
% basenames for classes we'll be using | |
ACMBasename='org.apache.commons.math3.linear.'; |
OlderNewer