49 #include "scip/pub_message.h"
50 #include "blockmemshell/memory.h"
51 #include "scip/type_retcode.h"
57 #define SDPA_VERSION 740
60 #define BMS_CALL(x) do \
64 SCIPerrorMessage("No memory in function call\n"); \
65 return SCIP_NOMEMORY; \
71 #define SCIP_RealTOINT(x) ((LAPACKINTTYPE) (x + 0.5))
82 char* JOBZ,
char* RANGE,
char* UPLO,
84 SCIP_Real* VL, SCIP_Real* VU,
86 SCIP_Real* ABSTOL,
LAPACKINTTYPE* M, SCIP_Real* W, SCIP_Real* Z,
116 SCIP_Bool geteigenvectors,
120 SCIP_Real* eigenvalue,
121 SCIP_Real* eigenvector
125 #if ( SDPA_VERSION == 740 )
150 assert( bufmem != NULL );
153 assert( 0 < i && i <= n );
154 assert( eigenvalue != NULL );
155 assert( ( ! geteigenvectors) || eigenvector != NULL );
158 JOBZ = geteigenvectors ?
'V' :
'N';
173 F77_FUNC(dsyevr, DSYEVR)( &JOBZ, &RANGE, &UPLO,
177 &ABSTOL, &M, NULL, NULL,
179 &LWORK, &WISIZE, &LIWORK,
184 SCIPerrorMessage(
"There was an error when calling DSYEVR. INFO = %lld\n", INFO);
192 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &WORK, (
int) LWORK) );
193 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &IWORK, (
int) LIWORK) );
194 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &WTMP, (
int) N) );
195 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &ISUPPZ, 2) );
201 F77_FUNC(dsyevr, DSYEVR)( &JOBZ, &RANGE, &UPLO,
205 &ABSTOL, &M, WTMP, eigenvector,
207 &LWORK, IWORK, &LIWORK,
212 SCIPerrorMessage(
"There was an error when calling DSYEVR. INFO = %d\n", INFO);
217 *eigenvalue = WTMP[0];
220 BMSfreeBufferMemoryArray(bufmem, &ISUPPZ);
221 BMSfreeBufferMemoryArray(bufmem, &WTMP);
222 BMSfreeBufferMemoryArray(bufmem, &IWORK);
223 BMSfreeBufferMemoryArray(bufmem, &WORK);
234 SCIP_Real* eigenvalues,
235 SCIP_Real* eigenvectors
239 #if ( SDPA_VERSION == 740 )
261 assert( bufmem != NULL );
264 assert( eigenvalues != NULL );
265 assert( eigenvectors != NULL );
281 F77_FUNC(dsyevr, DSYEVR)( &JOBZ, &RANGE, &UPLO,
285 &ABSTOL, &M, NULL, NULL,
287 &LWORK, &WISIZE, &LIWORK,
292 SCIPerrorMessage(
"There was an error when calling DSYEVR. INFO = %d\n", INFO);
300 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &WORK, (
int) LWORK) );
301 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &IWORK, (
int) LIWORK) );
302 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &ISUPPZ, (
int) 2 * N) );
308 F77_FUNC(dsyevr, DSYEVR)( &JOBZ, &RANGE, &UPLO,
312 &ABSTOL, &M, eigenvalues, eigenvectors,
314 &LWORK, IWORK, &LIWORK,
319 SCIPerrorMessage(
"There was an error when calling DSYEVR. INFO = %d\n", INFO);
324 BMSfreeBufferMemoryArray(bufmem, &ISUPPZ);
325 BMSfreeBufferMemoryArray(bufmem, &IWORK);
326 BMSfreeBufferMemoryArray(bufmem, &WORK);
365 F77_FUNC(dgemv, DGEMV)(&TRANS, &M, &N, &ALPHA, A, &LDA, X, &INCX, &BETA, Y, &INCY);
375 SCIP_Bool transposeA,
379 SCIP_Bool transposeB,
394 assert( (transposeA && transposeB && (nrowsA == ncolsB)) || (transposeA && !transposeB && (nrowsA == nrowsB))
395 || (!transposeA && transposeB && (ncolsA == ncolsB)) || (!transposeA && !transposeB && (ncolsA == nrowsB)) );
397 TRANSA = transposeA ?
'T' :
'N';
398 TRANSB = transposeB ?
'T' :
'N';
399 M = transposeA ? ncolsA : nrowsA;
400 N = transposeB ? nrowsB : ncolsB;
401 K = transposeA ? nrowsA : ncolsA;
403 LDA = transposeA ? K : M;
404 LDB = transposeB ? N : K;
408 F77_FUNC(dgemm, DGEMM)(&TRANSA, &TRANSB, &M, &N, &K, &ALPHA, matrixA, &LDA, matrixB, &LDB, &BETA, result, &LDC);
long long int LAPACKINTTYPE
SCIP_RETCODE SCIPlapackComputeEigenvectorDecomposition(BMS_BUFMEM *bufmem, int n, SCIP_Real *A, SCIP_Real *eigenvalues, SCIP_Real *eigenvectors)
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 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 SCIP_RealTOINT(x)
#define F77_FUNC(name, NAME)
interface methods for eigenvector computation and matrix multiplication using different versions of L...