MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
GPC_LAPACK_pinv Class Reference

#include <gpc.h>

Inheritance diagram for GPC_LAPACK_pinv:
Collaboration diagram for GPC_LAPACK_pinv:

Public Member Functions

 GPC_LAPACK_pinv (integer n, integer m)
 
 ~GPC_LAPACK_pinv (void)
 
integer Inv (integer ndima, integer nrowa, integer ncola, doublereal *a)
 
- Public Member Functions inherited from GPCInv
 GPCInv (void)
 
virtual ~GPCInv (void)
 

Protected Attributes

integer m
 
integer n
 
integer iMin
 
integer iMax
 
integer iWork
 
doublerealpdS
 
doublerealpdU
 
doublerealpdVt
 
doublerealpdWork
 
- Protected Attributes inherited from GPCInv
doublerealpdBase
 

Detailed Description

Definition at line 75 of file gpc.h.

Constructor & Destructor Documentation

GPC_LAPACK_pinv::GPC_LAPACK_pinv ( integer  n,
integer  m 
)

Definition at line 600 of file gpc.cc.

References ASSERT, iMax, iMin, iWork, n, GPCInv::pdBase, pdS, pdU, pdVt, pdWork, and SAFENEWARR.

601 : GPCInv(),
602 m(m), n(n),
603 iMin(0),
604 iMax(0),
605 iWork(0),
606 pdS(NULL),
607 pdU(NULL),
608 pdVt(NULL),
609 pdWork(NULL)
610 {
611  ASSERT(m > 0);
612  ASSERT(n > 0);
613 
614  iMin = std::min(m, n); /* usati per vari parametri */
615  iMax = std::max(m, n); /* serve solo qui, non serve tenerlo */
616 
617  iWork = std::max(3*iMin+iMax, 5*iMin-4); /* aumentare per maggiore eff. */
618 
619  /* aree di lavoro per SVD:
620  * s: (min(m,n))
621  * u: (ldu*min(m,n))
622  * ldu >= m
623  * vt: (ldvt*n)
624  * ldvt >= min(m,n)
625  * work: lwork
626  * lwork >= max(3*min(m,n)+max(m,n),5*min(m,n)-4)
627  */
628 
629  integer i = iMin /* s */
630  +m*iMin /* u */
631  +iMin*n /* vt */
632 #ifndef OPTIMIZE_WORK
633  +iWork; /* work */
634 #else /* OPTIMIZE_WORK */
635  ;
636 
637  /* per ottimizzare le dimensioni di work: viene allocato a parte */
638  SAFENEWARR(pdWork, doublereal, iWork);
639 #endif /* OPTIMIZE_WORK */
640 
642 
643  pdS = pdBase;
644  pdU = pdS+iMin;
645  pdVt = pdU+m*iMin;
646 
647 #ifndef OPTIMIZE_WORK
648  pdWork = pdVt+iMin*n;
649 #endif /* !OPTIMIZE_WORK */
650 }
integer n
Definition: gpc.h:78
doublereal * pdWork
Definition: gpc.h:88
doublereal * pdVt
Definition: gpc.h:87
doublereal * pdBase
Definition: gpc.h:55
doublereal * pdS
Definition: gpc.h:85
integer iMax
Definition: gpc.h:81
integer m
Definition: gpc.h:77
doublereal * pdU
Definition: gpc.h:86
integer iMin
Definition: gpc.h:80
#define ASSERT(expression)
Definition: colamd.c:977
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
integer iWork
Definition: gpc.h:83
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
GPCInv(void)
Definition: gpc.cc:582
GPC_LAPACK_pinv::~GPC_LAPACK_pinv ( void  )

Definition at line 652 of file gpc.cc.

References NO_OP, pdWork, and SAFEDELETEARR.

653 {
654 #ifndef OPTIMIZE_WORK
655  NO_OP; /* pdBase viene distrutto da GPCInv */
656 #else /* OPTIMIZE_WORK */
658 #endif /* OPTIMIZE_WORK */
659 }
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pdWork
Definition: gpc.h:88
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

integer GPC_LAPACK_pinv::Inv ( integer  ndima,
integer  nrowa,
integer  ncola,
doublereal a 
)
virtual

Implements GPCInv.

Definition at line 662 of file gpc.cc.

References ASSERT, gpc_pinv(), iMin, iWork, m, n, pdS, pdU, pdVt, pdWork, SAFEDELETEARR, and SAFENEWARR.

664 {
665  ASSERT(nrowa == m);
666  ASSERT(ncola == n);
667 
668  integer info = gpc_pinv(ndima, nrowa, ncola, a,
669  pdS, m, pdU, iMin, pdVt, iWork, pdWork);
670 
671  if (info != 0) {
672  return info;
673  }
674 
675 #ifdef OPTIMIZE_WORK
676  if (((integer *)pdWork)[0] > iWork) {
677  iWork = ((integer *)pdWork)[0];
680  }
681 #endif /* OPTIMIZE_WORK */
682 
683  return integer(0);
684 }
integer n
Definition: gpc.h:78
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pdWork
Definition: gpc.h:88
doublereal * pdVt
Definition: gpc.h:87
doublereal * pdS
Definition: gpc.h:85
static integer gpc_pinv(integer lda, integer m, integer n, doublereal *a, doublereal *s, integer ldu, doublereal *u, integer ldvt, doublereal *vt, integer lwork, doublereal *work)
Definition: gpc.cc:518
integer m
Definition: gpc.h:77
doublereal * pdU
Definition: gpc.h:86
integer iMin
Definition: gpc.h:80
#define ASSERT(expression)
Definition: colamd.c:977
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
static const doublereal a
Definition: hfluid_.h:289
integer iWork
Definition: gpc.h:83
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

Member Data Documentation

integer GPC_LAPACK_pinv::iMax
protected

Definition at line 81 of file gpc.h.

Referenced by GPC_LAPACK_pinv().

integer GPC_LAPACK_pinv::iMin
protected

Definition at line 80 of file gpc.h.

Referenced by GPC_LAPACK_pinv(), and Inv().

integer GPC_LAPACK_pinv::iWork
protected

Definition at line 83 of file gpc.h.

Referenced by GPC_LAPACK_pinv(), and Inv().

integer GPC_LAPACK_pinv::m
protected

Definition at line 77 of file gpc.h.

Referenced by Inv().

integer GPC_LAPACK_pinv::n
protected

Definition at line 78 of file gpc.h.

Referenced by GPC_LAPACK_pinv(), and Inv().

doublereal* GPC_LAPACK_pinv::pdS
protected

Definition at line 85 of file gpc.h.

Referenced by GPC_LAPACK_pinv(), and Inv().

doublereal* GPC_LAPACK_pinv::pdU
protected

Definition at line 86 of file gpc.h.

Referenced by GPC_LAPACK_pinv(), and Inv().

doublereal* GPC_LAPACK_pinv::pdVt
protected

Definition at line 87 of file gpc.h.

Referenced by GPC_LAPACK_pinv(), and Inv().

doublereal* GPC_LAPACK_pinv::pdWork
protected

Definition at line 88 of file gpc.h.

Referenced by GPC_LAPACK_pinv(), Inv(), and ~GPC_LAPACK_pinv().


The documentation for this class was generated from the following files: