@PROBLEM arpack_solver
@INCLUDE <math.h>
@FUNCTION dnstev_
@DASHI $(NETSOLVE_ROOT)/src/SampleNumericalSoftware/SparseSolvers/sparse/
@DASHI $(NETSOLVE_ROOT)/src/SampleNumericalSoftware/SparseSolvers/sparse/aux
@DASHI $(NETSOLVE_ROOT)/src/SampleNumericalSoftware/SparseSolvers/eigen
@LIB  $(NETSOLVE_ROOT)/src/SampleNumericalSoftware/SparseSolvers/eigen/lib/$(NETSOLVE_ARCH)/libnetsolve_arpack.a
@LIB $(NETSOLVE_ROOT)/src/SampleNumericalSoftware/SparseSolvers/sparse/lib/$(NETSOLVE_ARCH)/libnetsolve_aux.a
@LIB -L/src/icl2/Arpack/lib/linux
@LIB -larpack
@LIB -larpack_lapack
@LIB -L/usr/local/lib
@LIB -llapack
@LIB -lf77blas
@LIB -latlas
@LIB /src/icl2/SuperLU/lib/sequential/linux/superlu.a
@LIB /src/icl2/SuperLU/lib/sequential/linux/blas.a
@LIB /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/libg2c.a
@LIB -lm

@LANGUAGE C
@MAJOR ROW
@PATH /ARPACK/
@COMPLEXITY 3,2
@DESCRIPTION 
ARPACK solve using dnstev_ from SPEIG

@INPUT 3
@OBJECT SPARSEMATRIX D sm
the sparse matrix
@OBJECT SCALAR I wanted_vectors
number of eigenvalues requested
@OBJECT STRING which
which   (char*)   Specify which part of the spectrum is of interest.(INPUT)
                  which can be of the following type:
                  "LM"    --- eigenvalues with the largest magnitude.
                  "SM"    --- eigenvalues with the smallest magnitue.
                  "LR"    --- eigenvalues with the largest real part.
                  "SR"    --- eigenvalues with the smallest real part.
                  "LI"    --- eigenvalues with the largest imag part.
                  "SI"    --- eigenvalues with the largest imag part.
                  "shift" --- eigenvalues near a shift specified by
                              (sigmar, sigmai).
                  Note:
                  Eigenvalues with the smallest magnitude can
                  be computed by setting which to 'shift' using
                  zero as the shift.
@OUTPUT 4
@OBJECT VECTOR D real_ev
real part of the eigenvalue.
@OBJECT VECTOR D imag_ev
imaginary part of the eigenvalue.
@OBJECT VECTOR D final vectors
Eigenvector matrix
@OBJECT SCALAR I info
info     (int*)   Error flag to indicate whether the eigenvalues
                  calculation is successful. (OUTPUT)
                  *info = 0, successful exit
                  *info = 1, Maximum number of iteration is reached
                             before all requested eigenvalues
                             have converged.
@CALLINGSEQUENCE
@ARG mI0, nI0
@ARG fI0
@ARG I0
@ARG iI0
@ARG pI0
@ARG I1
@ARG I2
@ARG O0
@ARG O1
@ARG O2
@ARG O3

@CODE
extern void dnstev_();
double shift_r=1.,shift_i=.1; /* from CY's driver routine */
int i;

  if (strcasecmp(@I2@,"LM")==0)
     strcpy(@I2@,"LM");
  else if (strcasecmp(@I2@,"SM")==0)
     strcpy(@I2@,"SM");
  else if (strcasecmp(@I2@,"LR")==0)
     strcpy(@I2@,"LR");
  else if (strcasecmp(@I2@,"SR")==0)
     strcpy(@I2@,"SR");
  else if (strcasecmp(@I2@,"LI")==0)
     strcpy(@I2@,"LI");
  else if (strcasecmp(@I2@,"SI")==0)
     strcpy(@I2@,"SI");
  else if (strcasecmp(@I2@,"shift")==0)
     strcpy(@I2@,"shift");
  else
     return NS_PROT_BAD_VALUES;

  @O0@ = (double*)malloc((*@I1@+1)*sizeof(double));
  @O1@ = (double*)malloc((*@I1@+1)*sizeof(double));
  @O2@ = (double*)malloc((*@mI0@)*(*@I1@+1)*sizeof(double));

  @O3@ = (int *) malloc(sizeof(int));

  for(i=0; i<*@fI0@; i++) @iI0@[i]++;
  for(i=0; i<*@mI0@+1; i++) @pI0@[i]++;

  dnstev_(@mI0@, @I1@, @I2@, &shift_r, &shift_i, @pI0@, @iI0@, @I0@,
	@O0@, @O1@, @O2@, @mI0@, @O3@);

  *@mO0@ = *@I1@+1;
  *@mO1@ = *@I1@+1;
  *@mO2@ = (*@mI0@)*(*@I1@);



@END_CODE
