Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

cs_symeig.c File Reference

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "eispack.h"

Go to the source code of this file.


Functions

void symeig_double (int n, double *a, double *e)
void symeigval_double (int n, double *a, double *e)
void svd_double (int m, int n, double *a, double *s, double *u, double *v)

Function Documentation

void svd_double int    m,
int    n,
double *    a,
double *    s,
double *    u,
double *    v
 

Compute SVD of double precision matrix: T [a] = [u] diag[s] [v]

  • m = # of rows in a
  • n = # of columns in a
  • a = pointer to input matrix; a[i+j*m] has the (i,j) element
  • s = pointer to output singular values; length = n
  • u = pointer to output matrix, if desired; length = m*n
  • v = pointer to output matrix, if desired; length = n*n
----------------------------------------------------------------------

Definition at line 81 of file cs_symeig.c.

References a, free, malloc, svd_(), and v.

Referenced by DMAT_svd(), main(), matrix_psinv(), and mri_psinv().

00082 {
00083    integer mm,nn , lda,ldu,ldv , ierr ;
00084    doublereal *aa, *ww , *uu , *vv , *rv1 ;
00085    logical    matu , matv ;
00086 
00087    if( a == NULL || s == NULL || m < 1 || n < 1 ) return ;
00088 
00089    mm  = m ;
00090    nn  = n ;
00091    aa  = a ;
00092    lda = m ;
00093    ww  = s ;
00094 
00095    if( u == NULL ){
00096      matu = (logical) 0 ;
00097      uu   = (doublereal *)malloc(sizeof(double)*m*n) ;
00098    } else {
00099      matu = (logical) 1 ;
00100      uu = u ;
00101    }
00102    ldu = m ;
00103 
00104    if( v == NULL ){
00105      matv = (logical) 0 ;
00106      vv   = NULL ;
00107    } else {
00108      matv = (logical) 1 ;
00109      vv = v ;
00110    }
00111    ldv = n ;
00112 
00113    rv1 = (double *) malloc(sizeof(double)*n) ;  /* workspace */
00114 
00115    (void) svd_( &mm , &nn , &lda , aa , ww ,
00116                 &matu , &ldu , uu , &matv , &ldv , vv , &ierr , rv1 ) ;
00117 
00118    free((void *)rv1) ;
00119 
00120    if( u == NULL ) free((void *)uu) ;
00121    return ;
00122 }

void symeig_double int    n,
double *    a,
double *    e
 

Definition at line 25 of file cs_symeig.c.

References a, free, malloc, and rs_().

Referenced by DMAT_symeig(), EIG_func(), EIG_tsfunc(), and main().

00026 {
00027    integer nm , matz , ierr ;
00028    double *fv1 , *fv2 ;
00029 
00030    if( a == NULL || e == NULL || n < 1 ) return ;
00031 
00032    if( n == 1 ){
00033      e[0] = a[0] ; a[0] = 1.0 ; return ;  /* degenerate case */
00034    }
00035 
00036    fv1 = (double *) malloc(sizeof(double)*n) ;  /* workspaces */
00037    fv2 = (double *) malloc(sizeof(double)*n) ;
00038 
00039    nm = n ; matz = 1 ; ierr = 0 ;
00040 
00041    rs_( &nm , &nm , a , e , &matz , a , fv1 , fv2 , &ierr ) ;
00042 
00043    free((void *)fv1) ; free((void *)fv2) ;
00044    return ;
00045 }

void symeigval_double int    n,
double *    a,
double *    e
 

Definition at line 49 of file cs_symeig.c.

References a, free, malloc, and rs_().

Referenced by matrix_singvals().

00050 {
00051    integer nm , matz , ierr ;
00052    double *fv1 , *fv2 ;
00053 
00054    if( a == NULL || e == NULL || n < 1 ) return ;
00055 
00056    if( n == 1 ){ e[0] = a[0] ; return ; } /* degenerate case */
00057 
00058    fv1 = (double *) malloc(sizeof(double)*n) ;  /* workspaces */
00059    fv2 = (double *) malloc(sizeof(double)*n) ;
00060 
00061    nm = n ; matz = 0 ; ierr = 0 ;
00062 
00063    rs_( &nm , &nm , a , e , &matz , a , fv1 , fv2 , &ierr ) ;
00064 
00065    free((void *)fv1) ; free((void *)fv2) ;
00066    return ;
00067 }
 

Powered by Plone

This site conforms to the following standards: