00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <stdlib.h>
00012 #include <stdio.h>
00013 #include <math.h>
00014
00015 #include "CoinFinite.hpp"
00016 #include "CouenneConfig.h"
00017
00018
00019
00020 extern "C" {
00021
00022
00023
00024 void F77_FUNC(dsyev,DSYEV) (
00025 char *,
00026 char *,
00027 char *,
00028 int *,
00029 double *,
00030 int *,
00031 double *,
00032 double *,
00033 int *,
00034 int *,
00035 double *,
00036 int *,
00037 double *,
00038 double *,
00039 int *,
00040 double *,
00041 int *,
00042 int *,
00043 int *,
00044 int *);
00045 }
00046
00047
00048 int dsyevx_interface (int n, double *A, int &m,
00049 double * &w,
00050 double * &z,
00051 double tolerance,
00052 double lb_ev,
00053 double ub_ev,
00054 int firstidx,
00055 int lastidx) {
00056
00057 #ifdef DEBUG
00058
00059 printf ("matrix:\n---------------------------------\n");
00060 for (int i=0; i<n; ++i) {
00061 for (int j=0; j<n; ++j)
00062 printf ("%g ", A [i*n+j]);
00063 printf ("\n");
00064 }
00065 printf ("---------------------------------\n");
00066 #endif
00067
00068 if (NULL == w) w = new double [n];
00069 if (NULL == z) z = new double [n*n];
00070
00071 m = n;
00072
00073 int lwork = 8*n;
00074
00075 char jobz = 'V';
00076 char range = 'V';
00077 char uplo = 'U';
00078
00079 int il = firstidx;
00080 int iu = lastidx;
00081 int lda = n;
00082 int ldz = n;
00083
00084 int info;
00085
00086 int *ifail = new int [n];
00087 int *iwork = new int [5*n];
00088
00089 double abstol = tolerance;
00090 double vl = lb_ev;
00091 double vu = ub_ev;
00092
00093 double *work = new double [lwork];
00094
00095
00096
00097
00098 F77_FUNC
00099 (dsyev,DSYEV)
00100 (&jobz, &range, &uplo, &n,
00101 A, &lda,
00102 &vl, &vu, &il, &iu,
00103 &abstol, &m,
00104 w, z, &ldz, work, &lwork, iwork, ifail, &info);
00105
00106 if (info) {
00107 printf (":: dsyevx returned status %d\n", info);
00108 #ifdef CHECK
00109 for(int i=0; i<m; i++) {
00110 if(ifail[i] > 0) {
00111 printf("### WARNING: dsyevx_wrapper(): ifail[%d]: %d curr_ev[%d]=%.18f\n"
00112 , i, ifail [i], ifail [i], w [ifail [i]]);
00113 }
00114 }
00115 #endif
00116 }
00117
00118 delete [] work;
00119 delete [] ifail;
00120 delete [] iwork;
00121
00122 return m;
00123 }