49 #include "scip/pub_message.h"
50 #include "blockmemshell/memory.h"
51 #include "scip/type_retcode.h"
57 #define BMS_CALL(x) do \
61 SCIPerrorMessage("No memory in function call\n"); \
62 return SCIP_NOMEMORY; \
68 #define SCIP_RealTOINT(x) ((int) (x + 0.5))
79 char* JOBZ,
char* RANGE,
char* UPLO,
80 int* N, SCIP_Real* A,
int* LDA,
81 SCIP_Real* VL, SCIP_Real* VU,
83 SCIP_Real* ABSTOL,
int* M, SCIP_Real* W, SCIP_Real* Z,
84 int* LDZ,
int* ISUPPZ, SCIP_Real* WORK,
85 int* LWORK,
int* IWORK,
int* LIWORK,
90 void F77_FUNC(dgemv, DGEMV)(
char* TRANS,
int* M,
int* N, SCIP_Real* ALPHA, SCIP_Real* A,
int* LDA,
91 SCIP_Real* X,
int* INCX, SCIP_Real* BETA, SCIP_Real* Y,
int* INCY);
94 void F77_FUNC(dgemm, DGEMM)(
char* TRANSA,
char* TRANSB,
int* M,
int* N,
int* K, SCIP_Real* ALPHA,
95 SCIP_Real* A,
int* LDA, SCIP_Real* B,
int* LDB, SCIP_Real* BETA, SCIP_Real* C,
int* LDC );
110 SCIP_Bool geteigenvectors,
114 SCIP_Real* eigenvalue,
115 SCIP_Real* eigenvector
141 assert( bufmem != NULL );
144 assert( 0 < i && i <= n );
145 assert( eigenvalue != NULL );
146 assert( ( ! geteigenvectors) || eigenvector != NULL );
149 JOBZ = geteigenvectors ?
'V' :
'N';
164 F77_FUNC(dsyevr, DSYEVR)( &JOBZ, &RANGE, &UPLO,
168 &ABSTOL, &M, NULL, NULL,
170 &LWORK, &WISIZE, &LIWORK,
175 SCIPerrorMessage(
"There was an error when calling DSYEVR. INFO = %d\n", INFO);
183 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &WORK, LWORK) );
184 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &IWORK, LIWORK) );
185 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &WTMP, N) );
186 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &ISUPPZ, 2) );
192 F77_FUNC(dsyevr, DSYEVR)( &JOBZ, &RANGE, &UPLO,
196 &ABSTOL, &M, WTMP, eigenvector,
198 &LWORK, IWORK, &LIWORK,
203 SCIPerrorMessage(
"There was an error when calling DSYEVR. INFO = %d\n", INFO);
208 *eigenvalue = WTMP[0];
211 BMSfreeBufferMemoryArray(bufmem, &ISUPPZ);
212 BMSfreeBufferMemoryArray(bufmem, &WTMP);
213 BMSfreeBufferMemoryArray(bufmem, &IWORK);
214 BMSfreeBufferMemoryArray(bufmem, &WORK);
224 SCIP_Real* eigenvalues,
225 SCIP_Real* eigenvectors
229 #if ( SDPA_VERSION == 740 )
251 assert( bufmem != NULL );
254 assert( eigenvalues != NULL );
255 assert( eigenvectors != NULL );
271 F77_FUNC(dsyevr, DSYEVR)( &JOBZ, &RANGE, &UPLO,
275 &ABSTOL, &M, NULL, NULL,
277 &LWORK, &WISIZE, &LIWORK,
282 SCIPerrorMessage(
"There was an error when calling DSYEVR. INFO = %d\n", INFO);
290 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &WORK, (
int) LWORK) );
291 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &IWORK, (
int) LIWORK) );
292 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &ISUPPZ, (
int) 2 * N) );
298 F77_FUNC(dsyevr, DSYEVR)( &JOBZ, &RANGE, &UPLO,
302 &ABSTOL, &M, eigenvalues, eigenvectors,
304 &LWORK, IWORK, &LIWORK,
309 SCIPerrorMessage(
"There was an error when calling DSYEVR. INFO = %d\n", INFO);
314 BMSfreeBufferMemoryArray(bufmem, &ISUPPZ);
315 BMSfreeBufferMemoryArray(bufmem, &IWORK);
316 BMSfreeBufferMemoryArray(bufmem, &WORK);
354 F77_FUNC(dgemv, DGEMV)(&TRANS, &M, &N, &ALPHA, A, &LDA, X, &INCX, &BETA, Y, &INCY);
364 SCIP_Bool transposeA,
368 SCIP_Bool transposeB,
383 assert( (transposeA && transposeB && (nrowsA == ncolsB)) || (transposeA && !transposeB && (nrowsA == nrowsB))
384 || (!transposeA && transposeB && (ncolsA == ncolsB)) || (!transposeA && !transposeB && (ncolsA == nrowsB)) );
386 TRANSA = transposeA ?
'T' :
'N';
387 TRANSB = transposeB ?
'T' :
'N';
388 M = transposeA ? ncolsA : nrowsA;
389 N = transposeB ? nrowsB : ncolsB;
390 K = transposeA ? nrowsA : ncolsA;
392 LDA = transposeA ? K : M;
393 LDB = transposeB ? N : K;
397 F77_FUNC(dgemm, DGEMM)(&TRANSA, &TRANSB, &M, &N, &K, &ALPHA, matrixA, &LDA, matrixB, &LDB, &BETA, result, &LDC);
EXTERN SCIP_RETCODE SCIPlapackComputeIthEigenvalue(BMS_BUFMEM *bufmem, SCIP_Bool geteigenvectors, int n, SCIP_Real *A, int i, SCIP_Real *eigenvalue, SCIP_Real *eigenvector)
Macros for calling Fortran-functions.
SCIP_RETCODE SCIPlapackMatrixVectorMult(int nrows, int ncols, SCIP_Real *matrix, SCIP_Real *vector, SCIP_Real *result)
SCIP_RETCODE SCIPlapackComputeEigenvectorDecomposition(BMS_BUFMEM *bufmem, int n, SCIP_Real *A, SCIP_Real *eigenvalues, SCIP_Real *eigenvectors)
SCIP_RETCODE SCIPlapackMatrixMatrixMult(int nrowsA, int ncolsA, SCIP_Real *matrixA, SCIP_Bool transposeA, int nrowsB, int ncolsB, SCIP_Real *matrixB, SCIP_Bool transposeB, SCIP_Real *result)
#define F77_FUNC(name, NAME)
interface methods for eigenvector computation and matrix multiplication using different versions of L...
#define SCIP_RealTOINT(x)