pknumf.h

Go to the documentation of this file.
00001 
00002 /* ///////////////////////////////////////////////////////////////////////// */
00003 /* This file is a part of the BSTools package                                */
00004 /* written by Przemyslaw Kiciak                                              */
00005 /* ///////////////////////////////////////////////////////////////////////// */
00006 /* (C) Copyright by Przemyslaw Kiciak, 2005, 2013                            */
00007 /* this package is distributed under the terms of the                        */
00008 /* Lesser GNU Public License, see the file COPYING.LIB                       */
00009 /* ///////////////////////////////////////////////////////////////////////// */
00010 
00011 /* Header file for the libpknum library of C procedures - numerical methods */
00012 
00013 #ifndef CONST_  /* a dirty trick to suppress many compiler warning messages */
00014 #define CONST_ const
00015 #endif
00016 
00017 #ifndef PKNUMF_H
00018 #define PKNUMF_H
00019 
00020 #ifndef PKVARIA_H
00021 #include "pkvaria.h"
00022 #endif
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /* ///////////////////////////////////////////////////////////////////////// */
00029 #ifndef PKNUM_H
00030 typedef struct bandm_profile {
00031   int firstnz;  /* index of the first row with a nonzero  */
00032                 /* coefficient in the column */
00033   int ind;      /* index of this coefficient in the array */
00034 } bandm_profile;
00035 
00036 typedef struct { float x, y; } complexf;
00037 #endif
00038 
00039 /* ///////////////////////////////////////////////////////////////////////// */
00040 double pkn_ScalarProductf ( int spdimen, const float *a, const float *b );
00041 double pkn_SecondNormf ( int spdimen, const float *b );
00042 
00043 double pkn_detf ( int n, float *a );
00044 
00045 void pkn_AddMatrixf ( int nrows, int rowlen,
00046                       int inpitch1, const float *indata1,
00047                       int inpitch2, const float *indata2,
00048                       int outpitch, float *outdata );
00049 void pkn_AddMatrixMf ( int nrows, int rowlen,
00050                        int inpitch1, const float *indata1,
00051                        int inpitch2, const float *indata2,
00052                        double a,
00053                        int outpitch, float *outdata );
00054 void pkn_SubtractMatrixf ( int nrows, int rowlen,
00055                            int inpitch1, const float *indata1,
00056                            int inpitch2, const float *indata2,
00057                            int outpitch, float *outdata );
00058 void pkn_MatrixMDifferencef ( int nrows, int rowlen,
00059                               int inpitch1, const float *indata1,
00060                               int inpitch2, const float *indata2,
00061                               double a,
00062                               int outpitch, float *outdata );
00063 void pkn_MatrixLinCombf ( int nrows, int rowlen,
00064                           int inpitch1, const float *indata1,
00065                           double a,
00066                           int inpitch2, const float *indata2,
00067                           double b,
00068                           int outpitch, float *outdata );
00069 
00070 void pkn_MultMatrixNumf ( int nrows, int rowlen,
00071                           int inpitch, const float *indata, 
00072                           double a,
00073                           int outpitch, float *outdata );
00074 void pkn_MultArrayf ( int nrows, int rowlen, int pitch_a, CONST_ float *a,
00075                       int pitch_b, CONST_ float *b,
00076                       int pitch_c, float *c );
00077 
00078 void pkn_MultMatrixf ( int nrows_a, int rowlen_a, int pitch_a, CONST_ float *a,
00079                        int rowlen_b, int pitch_b, CONST_ float *b,
00080                        int pitch_c, float *c );
00081 void pkn_MultMatrixAddf ( int nrows_a, int rowlen_a, int pitch_a, CONST_ float *a,
00082                           int rowlen_b, int pitch_b, CONST_ float *b,
00083                           int pitch_c, float *c );
00084 void pkn_MultMatrixSubf ( int nrows_a, int rowlen_a, int pitch_a, CONST_ float *a,
00085                           int rowlen_b, int pitch_b, CONST_ float *b,
00086                           int pitch_c, float *c );
00087 
00088 void pkn_MultTMatrixf ( int nrows_a, int rowlen_a, int pitch_a, const float *a,
00089                         int rowlen_b, int pitch_b, const float *b,
00090                         int pitch_c, float *c );
00091 void pkn_MultTMatrixAddf ( int nrows_a, int rowlen_a, int pitch_a,
00092                            const float *a,
00093                            int rowlen_b, int pitch_b, const float *b,
00094                            int pitch_c, float *c );
00095 void pkn_MultTMatrixSubf ( int nrows_a, int rowlen_a, int pitch_a,
00096                            const float *a,
00097                            int rowlen_b, int pitch_b, const float *b,
00098                            int pitch_c, float *c );
00099 void pkn_MultMatrixTf ( int nrows_a, int rowlen_a, int pitch_a, const float *a,
00100                         int nrows_b, int pitch_b, const float *b,
00101                         int pitch_c, float *c );
00102 void pkn_MultMatrixTAddf ( int nrows_a, int rowlen_a, int pitch_a, const float *a,
00103                            int nrows_b, int pitch_b, const float *b,
00104                            int pitch_c, float *c );
00105 void pkn_MultMatrixTSubf ( int nrows_a, int rowlen_a, int pitch_a, const float *a,
00106                            int nrows_b, int pitch_b, const float *b,
00107                            int pitch_c, float *c );
00108 
00109 /* ///////////////////////////////////////////////////////////////////////// */
00110 void pkn_FindGivensRotationf ( float a, float b, float *c, float *s );
00111 void pkn_FindGivensRotXif ( float a, float b, float *c, float *s, float *xi );
00112 void pkn_FindXiGivensRotf ( float xi, float *c, float *s );
00113 void pkn_ApplyGivensRotationf ( float c, float s, float *a, float *b );
00114 void pkn_ApplySymGivensRotationf ( float c, float s,
00115                                    float *d, float *e, float *f );
00116 
00117 /* ///////////////////////////////////////////////////////////////////////// */
00118 void pkn_MVectorSumf ( int m, int n, float *sum, ... );
00119 void pkn_MVectorLinCombf ( int m, int n, float *sum, ... );
00120 
00121 /* ///////////////////////////////////////////////////////////////////////// */
00122 boolean pkn_GaussDecomposePLUQf ( int n, float *a, int *P, int *Q );
00123 void pkn_multiSolvePLUQf ( int n, const float *lu, const int *P, const int *Q,
00124                            int spdimen, int pitch, float *b );
00125 boolean pkn_multiGaussSolveLinEqf ( int n, const float *a,
00126                                     int spdimen, int pitch, float *b );
00127 boolean pkn_GaussInvertMatrixf ( int n, float *a );
00128 
00129 /* ///////////////////////////////////////////////////////////////////////// */
00130 boolean pkn_QRDecomposeMatrixf ( int nrows, int ncols, float *a, float *aa );
00131 void pkn_multiReflectVectorf ( int nrows, int ncols,
00132                                const float *a, const float *aa,
00133                                int spdimen, int pitch, float *b );
00134 void pkn_multiInvReflectVectorf ( int nrows, int ncols,
00135                                   const float *a, const float *aa,
00136                                   int spdimen, int pitch, float *b );
00137 void pkn_multiMultUTVectorf ( int nrows, const float *a,
00138                               int spdimen, int bpitch, float *b,
00139                               int xpitch, float *x );
00140 void pkn_multiMultInvUTVectorf ( int nrows, const float *a,
00141                                  int spdimen, int bpitch, float *b,
00142                                  int xpitch, float *x );
00143 void pkn_multiMultTrUTVectorf ( int nrows, const float *a,
00144                                 int spdimen, int bpitch, float *b,   
00145                                 int xpitch, float *x );
00146 void pkn_multiMultInvTrUTVectorf ( int nrows, const float *a,
00147                                    int spdimen, int bpitch, float *b,   
00148                                    int xpitch, float *x );
00149 boolean pkn_multiSolveRLSQf ( int nrows, int ncols, float *a,
00150                               int spdimen, int bpitch, float *b,
00151                               int xpitch, float *x );
00152 void pkn_QRGetReflectionf ( int nrows, int ncols,
00153                             const float *a, const float *aa,
00154                             int nrefl, float *w, float *gamma );
00155 
00156 
00157 /* ///////////////////////////////////////////////////////////////////////// */
00158 #ifndef PKNUM_H
00159 void pkn_BandmFindQRMSizes ( int ncols, const bandm_profile *aprof,
00160                              int *qsize, int *rsize );
00161 #endif
00162 
00163 void pkn_BandmQRDecomposeMatrixf ( int nrows, int ncols,
00164                                   const bandm_profile *aprof, const float *a,
00165                                   bandm_profile *qprof, float *q,
00166                                   bandm_profile *rprof, float *r );
00167 void pkn_multiBandmReflectVectorf ( int ncols,
00168                                     const bandm_profile *qprof, const float *q,
00169                                     int spdimen, float *b );
00170 void pkn_multiBandmInvReflectVectorf ( int ncols,
00171                                        const bandm_profile *qprof,
00172                                        const float *q,
00173                                        int spdimen, float *b );
00174 void pkn_multiBandmMultVectorf ( int nrows, int ncols,
00175                                  const bandm_profile *aprof, const float *a,
00176                                  int spdimen, const float *x, float *y );
00177 void pkn_multiBandmMultInvUTMVectorf ( int nrows,
00178                                        const bandm_profile *rprof,
00179                                        const float *r,
00180                                        int spdimen, const float *x, float *y );
00181 void pkn_multiBandmMultTrVectorf ( int ncols,
00182                                    const bandm_profile *aprof, const float *a,
00183                                    int spdimen, const float *x, float *y );
00184 void pkn_multiBandmMultInvTrUTMVectorf ( int nrows,
00185                                          const bandm_profile *rprof,
00186                                          const float *r,
00187                                          int spdimen, const float *x, float *y );
00188 
00189 void pkn_multiBandmSolveRLSQf ( int nrows, int ncols,
00190                                 const bandm_profile *aprof, const float *a,
00191                                 int nrsides, int spdimen,
00192                                 int bpitch, const float *b,
00193                                 int xpitch, float *x );
00194 void pkn_multiBandmSolveDLSQf ( int nrows, int ncols,
00195                                 const bandm_profile *atprof, const float *at,
00196                                 int nrsides, int spdimen,
00197                                 int bpitch, const float *b,
00198                                 int x0pitch, const float *x0,
00199                                 int xpitch, float *x );
00200 void pkn_multiBandmSolveCRLSQf ( int nrows, int ncols,
00201                                  const bandm_profile *aprof, const float *a,
00202                                  int nconstr, int cpitch, const float *c,
00203                                  int nrsides, int spdimen,
00204                                  int bpitch, const float *b,
00205                                  int dpitch, const float *d,
00206                                  int xpitch, float *x );
00207 
00208 void pkn_PrintBandmf ( int ncols, const bandm_profile *aprof, const float *a );
00209 void pkn_PrintBandmRowSumf ( int ncols, const bandm_profile *aprof, const float *a );
00210 void pkn_PrintMatf ( int nrows, int ncols, const float *a );
00211 
00212 #ifndef PKNUM_H
00213 void pkn_PrintProfile ( int ncols, const bandm_profile *prof );
00214 #endif
00215 
00216 /* ///////////////////////////////////////////////////////////////////////// */
00217 #ifndef PKNUM_H
00218 #define pkn_LowerTrMatIndex(i,j) \
00219   ( (i)*((i)+1)/2+(j) )
00220 #define pkn_SymMatIndex(i,j) \
00221   ( (i) >= (j) ? (i)*((i)+1)/2+(j) : (j)*((j)+1)/2+(i) )
00222 #endif
00223 
00224 boolean pkn_CholeskyDecompf ( int n, float *a );
00225 void pkn_SymMatrixMultf ( int n, CONST_ float *a, int spdimen,
00226                           int bpitch, CONST_ float *b,
00227                           int xpitch, float *x );
00228 void pkn_LowerTrMatrixMultf ( int n, CONST_ float *l, int spdimen,
00229                               int bpitch, CONST_ float *b,
00230                               int xpitch, float *x );
00231 void pkn_UpperTrMatrixMultf ( int n, CONST_ float *l, int spdimen,
00232                               int bpitch, CONST_ float *b,
00233                               int xpitch, float *x );
00234 void pkn_LowerTrMatrixSolvef ( int n, const float *l, int spdimen,
00235                                int bpitch, const float *b,
00236                                int xpitch, float *x );
00237 void pkn_UpperTrMatrixSolvef ( int n, const float *l, int spdimen,
00238                                int bpitch, const float *b,
00239                                int xpitch, float *x );
00240 
00241 void pkn_MatrixLowerTrMultf ( int m, int n, int bpitch, CONST_ float *b,
00242                               CONST_ float *l, int xpitch, float *x );
00243 void pkn_MatrixUpperTrMultf ( int m, int n, int bpitch, CONST_ float *b,
00244                               CONST_ float *l, int xpitch, float *x );
00245 void pkn_MatrixLowerTrSolvef ( int m, int n, int bpitch, CONST_ float *b,
00246                                CONST_ float *l, int xpitch, float *x );
00247 void pkn_MatrixUpperTrSolvef ( int m, int n, int bpitch, CONST_ float *b,
00248                                CONST_ float *l, int xpitch, float *x );
00249 void pkn_MatrixLowerTrMultAddf ( int m, int n, int bpitch, CONST_ float *b,
00250                                  CONST_ float *l, int xpitch, float *x );
00251 void pkn_MatrixUpperTrMultAddf ( int m, int n, int bpitch, CONST_ float *b,
00252                                  CONST_ float *l, int xpitch, float *x );
00253 boolean pkn_MatrixLowerTrSolveAddf ( int m, int n, int bpitch, CONST_ float *b,
00254                                      CONST_ float *l, int xpitch, float *x );
00255 boolean pkn_MatrixUpperTrSolveAddf ( int m, int n, int bpitch, CONST_ float *b,
00256                                      CONST_ float *l, int xpitch, float *x );
00257 void pkn_MatrixLowerTrMultSubf ( int m, int n, int bpitch, CONST_ float *b,
00258                                  CONST_ float *l, int xpitch, float *x );
00259 void pkn_MatrixUpperTrMultSubf ( int m, int n, int bpitch, CONST_ float *b,
00260                                  CONST_ float *l, int xpitch, float *x );
00261 boolean pkn_MatrixLowerTrSolveSubf ( int m, int n, int bpitch, CONST_ float *b,
00262                                      CONST_ float *l, int xpitch, float *x );
00263 boolean pkn_MatrixUpperTrSolveSubf ( int m, int n, int bpitch, CONST_ float *b,
00264                                      CONST_ float *l, int xpitch, float *x );
00265 
00266 void pkn_SymToFullMatrixf ( int n, const float *syma,
00267                             int pitch, float *fulla );
00268 void pkn_FullToSymMatrixf ( int n, int pitch, const float *fulla,
00269                             float *syma );
00270 #define pkn_FullToLTrMatrixf(n,pitch,fulla,ltra) \
00271   pkn_FullToSymMatrixf(n,pitch,fulla,ltra)
00272 void pkn_LTrToFullMatrixf ( int n, const float *ltra,
00273                             int pitch, float *fulla );
00274 void pkn_UTrToFullMatrixf ( int n, const float *utra,
00275                             int pitch, float *fulla );
00276 void pkn_FullToUTrMatrixf ( int n, int pitch, const float *fulla,
00277                             float *utra );
00278 
00279 void pkn_ComputeQSQTf ( int m, const float *s,   
00280                         int n, const float *a, const float *aa,
00281                         float *b );
00282 void pkn_ComputeQTSQf ( int m, const float *s,
00283                         int n, const float *a, const float *aa,
00284                         float *b );
00285 
00286 void pkn_SymMatSubAATf ( int n, float *b, int m, int pitch_a, CONST_ float *a );
00287 
00288 void pkn_SymMatFindEigenvalueIntervalf ( int n, float *a,
00289                                          float *lmin, float *lmax );
00290 boolean pkn_SymMatFindEigenvaluesf ( int n, float *a, float *eigenval );
00291 
00292 /* ///////////////////////////////////////////////////////////////////////// */
00293 #ifndef PKNUM_H
00294 #define pkn_LHessenbergMatIndex(i,j) \
00295   (pkn_LowerTrMatIndex(((i)+1),(j))-1)
00296 #define pkn_UHessenbergMatIndex(i,j) \
00297   (pkn_LowerTrMatIndex(((j)+1),(i))-1)
00298 #endif
00299 
00300 boolean pkn_QRDecompUHessenbergf ( int n, float *ah );
00301 void pkn_multiSolveQRUHessenbergf ( int n, float *qrh,
00302                                     int spdimen, int pitch, float *b );
00303 boolean pkn_multiSolveUHessenbergLinEqf ( int n, float *ah,
00304                                           int spdimen, int pitch, float *b );
00305 
00306 /* ///////////////////////////////////////////////////////////////////////// */
00307 float pkn_Illinoisf ( float (*f) (float), float a, float b, float eps,
00308                       boolean *error );
00309 
00310 boolean pkn_SolveSqEqf ( float p, float q, float *x1, float *x2 );
00311 
00312 float pkn_GoldenRatf ( float (*f) (float), float a, float b, float eps,     
00313                        boolean *error );
00314 
00315 
00316 /* ///////////////////////////////////////////////////////////////////////// */
00317 void pkn_Setup2DerA11Matrixf ( float xu, float yu, float xv, float yv,
00318                                float *A11 );
00319 
00320 void pkn_Setup2DerA21Matrixf ( float xuu, float yuu, float xuv,
00321                                float yuv, float xvv, float yvv,
00322                                float *A21 );
00323 void pkn_Setup2DerA22Matrixf ( float xu, float yu, float xv, float yv,
00324                                float *A22 );
00325 
00326 void pkn_Setup2DerA31Matrixf ( float xuuu, float yuuu, float xuuv, float yuuv,
00327                                float xuvv, float yuvv, float xvvv, float yvvv,
00328                                float *A31 );
00329 void pkn_Setup2DerA32Matrixf ( float xu, float yu, float xv, float yv,
00330                                float xuu, float yuu, float xuv,
00331                                float yuv, float xvv, float yvv,
00332                                float *A32 );
00333 void pkn_Setup2DerA33Matrixf ( float xu, float yu, float xv, float yv,
00334                                float *A33 );
00335 
00336 void pkn_Setup2DerA41Matrixf ( float xuuuu, float yuuuu, float xuuuv, float yuuuv,
00337                                float xuuvv, float yuuvv, float xuvvv, float yuvvv,
00338                                float xvvvv, float yvvvv,
00339                                float *A41 );
00340 void pkn_Setup2DerA42Matrixf ( float xu, float yu, float xv, float yv,
00341                                float xuu, float yuu, float xuv,
00342                                float yuv, float xvv, float yvv,
00343                                float xuuu, float yuuu, float xuuv, float yuuv,
00344                                float xuvv, float yuvv, float xvvv, float yvvv,
00345                                float *A42 );
00346 void pkn_Setup2DerA43Matrixf ( float xu, float yu, float xv, float yv,
00347                                float xuu, float yuu, float xuv,
00348                                float yuv, float xvv, float yvv,
00349                                float *A43 );
00350 void pkn_Setup2DerA44Matrixf ( float xu, float yu, float xv, float yv,
00351                                float *A44 );
00352 
00353 
00354 void pkn_Comp2Derivatives1f ( float xu, float yu, float xv, float yv,
00355                               int spdimen, const float *gx, const float *gy,
00356                               float *hu, float *hv );
00357 void pkn_Comp2Derivatives2f ( float xu, float yu, float xv, float yv,
00358                               float xuu, float yuu, float xuv,
00359                               float yuv, float xvv, float yvv,
00360                               int spdimen,
00361                               const float *gx, const float *gy,
00362                               const float *gxx, const float *gxy,
00363                               const float *gyy,
00364                               float *huu, float *huv, float *hvv );
00365 void pkn_Comp2Derivatives3f ( float xu, float yu, float xv, float yv,
00366                               float xuu, float yuu, float xuv,
00367                               float yuv, float xvv, float yvv,
00368                               float xuuu, float yuuu, float xuuv, float yuuv,
00369                               float xuvv, float yuvv, float xvvv, float yvvv,
00370                               int spdimen,
00371                               const float *gx, const float *gy,
00372                               const float *gxx, const float *gxy,
00373                               const float *gyy,
00374                               const float *gxxx, const float *gxxy,
00375                               const float *gxyy, const float *gyyy,
00376                               float *huuu, float *huuv,
00377                               float *huvv, float *hvvv );
00378 void pkn_Comp2Derivatives4f ( float xu, float yu, float xv, float yv,
00379                               float xuu, float yuu, float xuv,
00380                               float yuv, float xvv, float yvv,
00381                               float xuuu, float yuuu, float xuuv, float yuuv,
00382                               float xuvv, float yuvv, float xvvv, float yvvv,
00383                               float xuuuu, float yuuuu, float xuuuv,
00384                               float yuuuv, float xuuvv, float yuuvv,
00385                               float xuvvv, float yuvvv,
00386                               float xvvvv, float yvvvv,
00387                               int spdimen,
00388                               const float *gx, const float *gy,
00389                               const float *gxx, const float *gxy,
00390                               const float *gyy,
00391                               const float *gxxx, const float *gxxy,
00392                               const float *gxyy, const float *gyyy,
00393                               const float *gxxxx, const float *gxxxy,
00394                               const float *gxxyy, const float *gxyyy,
00395                               const float *gyyyy,
00396                               float *huuuu, float *huuuv, float *huuvv,
00397                               float *huvvv, float *hvvvv );
00398 
00399 
00400 void pkn_Comp2iDerivatives1f ( float xu, float yu, float xv, float yv,
00401                                int spdimen, const float *hu, const float *hv,
00402                                float *gx, float *gy );
00403 void pkn_Comp2iDerivatives2f ( float xu, float yu, float xv, float yv,
00404                                float xuu, float yuu, float xuv,
00405                                float yuv, float xvv, float yvv,
00406                                int spdimen,
00407                                const float *hu, const float *hv,
00408                                const float *huu, const float *huv,
00409                                const float *hvv,
00410                                float *gx, float *gy,
00411                                float *gxx, float *gxy, float *gyy );
00412 void pkn_Comp2iDerivatives3f ( float xu, float yu, float xv, float yv,
00413                                float xuu, float yuu, float xuv,
00414                                float yuv, float xvv, float yvv,
00415                                float xuuu, float yuuu, float xuuv, float yuuv,
00416                                float xuvv, float yuvv, float xvvv, float yvvv,
00417                                int spdimen,
00418                                const float *hu, const float *hv,
00419                                const float *huu, const float *huv,
00420                                const float *hvv,
00421                                const float *huuu, const float *huuv,
00422                                const float *huvv, const float *hvvv,
00423                                float *gx, float *gy,
00424                                float *gxx, float *gxy, float *gyy,
00425                                float *gxxx, float *gxxy,
00426                                float *gxyy, float *gyyy );
00427 void pkn_Comp2iDerivatives4f ( float xu, float yu, float xv, float yv,
00428                                float xuu, float yuu, float xuv,
00429                                float yuv, float xvv, float yvv,
00430                                float xuuu, float yuuu, float xuuv, float yuuv,
00431                                float xuvv, float yuvv, float xvvv, float yvvv,
00432                                float xuuuu, float yuuuu, float xuuuv,
00433                                float yuuuv, float xuuvv, float yuuvv,
00434                                float xuvvv, float yuvvv,
00435                                float xvvvv, float yvvvv,
00436                                int spdimen,
00437                                const float *hu, const float *hv,
00438                                const float *huu, const float *huv,
00439                                const float *hvv,
00440                                const float *huuu, const float *huuv,
00441                                const float *huvv, const float *hvvv,
00442                                const float *huuuu, const float *huuuv,
00443                                const float *huuvv, const float *huvvv,
00444                                const float *hvvvv,
00445                                float *gx, float *gy,
00446                                float *gxx, float *gxy, float *gyy,
00447                                float *gxxx, float *gxxy,
00448                                float *gxyy, float *gyyy,
00449                                float *gxxxx, float *gxxxy, float *gxxyy,
00450                                float *gxyyy, float *gyyyy );
00451 
00452 
00453 void pkn_f2iDerivatives1f ( float xu, float yu, float xv, float yv,
00454                             float *gx, float *gy );
00455 void pkn_f2iDerivatives2f ( float xu, float yu, float xv, float yv,
00456                             float xuu, float yuu, float xuv,
00457                             float yuv, float xvv, float yvv,
00458                             float *gx, float *gy,
00459                             float *gxx, float *gxy, float *gyy );
00460 void pkn_f2iDerivatives3f ( float xu, float yu, float xv, float yv,
00461                             float xuu, float yuu, float xuv,
00462                             float yuv, float xvv, float yvv,
00463                             float xuuu, float yuuu, float xuuv, float yuuv,
00464                             float xuvv, float yuvv, float xvvv, float yvvv,
00465                             float *gx, float *gy,
00466                             float *gxx, float *gxy, float *gyy,
00467                             float *gxxx, float *gxxy,
00468                             float *gxyy, float *gyyy );
00469 void pkn_f2iDerivatives4f ( float xu, float yu, float xv, float yv,
00470                             float xuu, float yuu, float xuv,
00471                             float yuv, float xvv, float yvv,
00472                             float xuuu, float yuuu, float xuuv, float yuuv,
00473                             float xuvv, float yuvv, float xvvv, float yvvv,
00474                             float xuuuu, float yuuuu, float xuuuv,
00475                             float yuuuv, float xuuvv, float yuuvv,
00476                             float xuvvv, float yuvvv,
00477                             float xvvvv, float yvvvv,
00478                             float *gx, float *gy,
00479                             float *gxx, float *gxy, float *gyy,
00480                             float *gxxx, float *gxxy,
00481                             float *gxyy, float *gyyy,
00482                             float *gxxxx, float *gxxxy, float *gxxyy,
00483                             float *gxyyy, float *gyyyy );
00484 
00485 
00486 /* ///////////////////////////////////////////////////////////////////////// */
00487 #ifndef PKNUM_H
00488 int pkn_Block1ArraySize ( int k, int r, int s );
00489 int pkn_Block1FindBlockPos ( int k, int r, int s, int i, int j );
00490 int pkn_Block1FindElemPos ( int k, int r, int s, int i, int j );
00491 #endif
00492 
00493 boolean pkn_Block1CholeskyDecompMf ( int k, int r, int s, float *A );
00494 void pkn_Block1LowerTrMSolvef ( int k, int r, int s, CONST_ float *A,
00495                                 int spdimen, int xpitch, float *x );
00496 void pkn_Block1UpperTrMSolvef ( int k, int r, int s, CONST_ float *A,
00497                                 int spdimen, int xpitch, float *x );
00498 void pkn_Block1SymMatrixMultf ( int k, int r, int s, CONST_ float *A,
00499                                 int spdimen, int xpitch, float *x,
00500                                 int ypitch, float *y );
00501 
00502 
00503 /* ///////////////////////////////////////////////////////////////////////// */
00504 int pkn_FFTPermutef ( int n, int rowlen, int pitch, complexf *a );
00505 boolean pkn_FFTf ( int n, int rowlen, int pitch, complexf *a );
00506 boolean pkn_InvFFTf ( int n, int rowlen, int pitch, complexf *a );
00507 
00508 
00509 /* ///////////////////////////////////////////////////////////////////////// */
00510 #ifndef PKNUM_H
00511 int pkn_Block2ArraySize ( int k, int r, int s, int t );
00512 int pkn_Block2FindBlockPos ( int k, int r, int s, int t, int i, int j );
00513 int pkn_Block2FindElemPos ( int k, int r, int s, int t, int i, int j );
00514 #endif
00515 
00516 boolean pkn_Block2CholeskyDecompMf ( int k, int r, int s, int t, float *A );
00517 void pkn_Block2LowerTrMSolvef ( int k, int r, int s, int t, CONST_ float *L,
00518                                 int spdimen, int xpitch, float *x );
00519 void pkn_Block2UpperTrMSolvef ( int k, int r, int s, int t, CONST_ float *L,
00520                                 int spdimen, int xpitch, float *x );
00521 void pkn_Block2SymMatrixMultf ( int k, int r, int s, int t, CONST_ float *A,
00522                                 int spdimen, int xpitch, CONST_ float *x,
00523                                 int ypitch, float *y );
00524 
00525 /* ///////////////////////////////////////////////////////////////////////// */
00526 #ifndef PKNUM_H
00527 int pkn_Block3ArraySize ( int k, int r, int s );
00528 int pkn_Block3FindBlockPos ( int k, int r, int s, int i, int j );
00529 int pkn_Block3FindElemPos ( int k, int r, int s, int i, int j );
00530 #endif
00531 
00532 boolean pkn_Block3CholeskyDecompMf ( int k, int r, int s, float *A );
00533 void pkn_Block3LowerTrMSolvef ( int k, int r, int s, CONST_ float *L,
00534                                 int spdimen, int xpitch, float *x );
00535 void pkn_Block3UpperTrMSolvef ( int k, int r, int s, CONST_ float *L,
00536                                 int spdimen, int xpitch, float *x );
00537 
00538 void pkn_Block3SymMatrixMultf ( int k, int r, int s, CONST_ float *A,
00539                                 int spdimen, int xpitch, CONST_ float *x,
00540                                 int ypitch, float *y );
00541 
00542 /* ///////////////////////////////////////////////////////////////////////// */
00543 #ifndef PKNUM_H
00544 int pkn_NRBArraySize ( int n, const int *prof );
00545 #endif
00546 
00547 boolean pkn_NRBFindRowsf ( int n, const int *prof, CONST_ float *a,
00548                            float **row );
00549 boolean pkn_NRBSymCholeskyDecompf ( int n, const int *prof, float *a,
00550                                     float **row, boolean *abort );
00551 boolean pkn_NRBSymMultf ( int n, const int *prof, CONST_ float *a,
00552                           float **row,
00553                           int spdimen, int xpitch, CONST_ float *x,
00554                           int ypitch, float *y );
00555 boolean pkn_NRBLowerTrMultf ( int n, const int *prof, CONST_ float *a,
00556                               float **row,
00557                               int spdimen, int xpitch, CONST_ float *x,
00558                               int ypitch, float *y );
00559 boolean pkn_NRBUpperTrMultf ( int n, const int *prof, CONST_ float *a,
00560                               float **row,
00561                               int spdimen, int xpitch, CONST_ float *x,
00562                               int ypitch, float *y );
00563 boolean pkn_NRBLowerTrSolvef ( int n, const int *prof, CONST_ float *l,
00564                                float **row,
00565                                int spdimen, int bpitch, CONST_ float *b,
00566                                int xpitch, float *x );
00567 boolean pkn_NRBUpperTrSolvef ( int n, const int *prof, CONST_ float *l,
00568                                float **row,
00569                                int spdimen, int bpitch, CONST_ float *b,
00570                                int xpitch, float *x );
00571 
00572 boolean pkn_NRBSymFindEigenvalueIntervalf ( int n, const int *prof,
00573                                             float *a, float **row,
00574                                             float *amin, float *amax );
00575 
00576 boolean pkn_NRBComputeQTSQf ( int n, int *prof, float *Amat, float **Arows,
00577                               int w, float *Bmat, float *bb,
00578                               int *qaprof, float **QArows );
00579 boolean pkn_NRBComputeQSQTf ( int n, int *prof, float *Amat, float **Arows,
00580                               int w, float *Bmat, float *bb,
00581                               int *qaprof, float **QArows );
00582 
00583 boolean pkn_NRBComputeQTSQblf ( int n, int *prof, float *Amat, float **Arows,
00584                                 int w, float *Bmat, float *bb,
00585                                 int *qa11prof, float **QA11rows,
00586                                 int *qa22prof, float **QA22rows,
00587                                 float **QA21 );
00588 boolean pkn_NRBComputeQSQTblf ( int n, int *prof, float *Amat, float **Arows,
00589                                 int w, float *Bmat, float *bb,
00590                                 int *qa11prof, float **QA11rows,
00591                                 int *qa22prof, float **QA22rows,
00592                                 float **QA21 );
00593 
00594 /* ///////////////////////////////////////////////////////////////////////// */
00595 boolean pkn_PCGf ( int n, void *usrdata, float *b, float *x,
00596             boolean (*multAx)( int n, void *usrdata, const float *x, float *Ax ),
00597             boolean (*multQIx)( int n, void *usrdata, const float *x, float *Qix ),
00598             int maxit, float eps, float delta, int *itm );
00599 
00600 /* ///////////////////////////////////////////////////////////////////////// */
00601 boolean pkn_MultSPMVectorf ( int nrows, int ncols, int nnz,
00602                              const index2 *ai, const float *ac,
00603                              int spdimen, const float *x,
00604                              float *y );
00605 boolean pkn_MultSPMTVectorf ( int nrows, int ncols, int nnz,
00606                               const index2 *ai, const float *ac,
00607                               int spdimen, const float *x,
00608                               float *y );
00609 
00610 boolean pkn_MultSPsubMVectorf ( int nrows, int ncols, int nnz,
00611                                 const index3 *ai, const float *ac,
00612                                 int spdimen, const float *x,
00613                                 float *y );
00614 boolean pkn_MultSPsubMTVectorf ( int nrows, int ncols, int nnz,
00615                                  const index3 *ai, const float *ac,
00616                                  int spdimen, const float *x,
00617                                  float *y );
00618 
00619 /* fast sparse matrix multiplication - uses data produced by */
00620 /* one of the pkn_SPMFind*nnz* or pkn_SPsubMFind*nnz* procedures */
00621 void pkn_SPMFastMultMMf ( float *ac, float *bc,
00622                           int nnzab, int *abpos, index2 *aikbkj,
00623                           float *abc );
00624 
00625 /* slower (but still decent) matrix multiplication procedures */
00626 boolean pkn_SPMmultMMCf ( int nra, int nca, int ncb,
00627                           unsigned int nnza, index2 *ai, float *ac,
00628                           unsigned int *apermut, int *acols, boolean ca,
00629                           unsigned int nnzb, index2 *bi, float *bc,
00630                           unsigned int *bpermut, int *bcols, boolean cb,
00631                           index2 *abi, float *abc );
00632 boolean pkn_SPMmultMMTCf ( int nra, int nca, int nrb,
00633                            unsigned int nnza, index2 *ai, float *ac,
00634                            unsigned int *apermut, int *acols, boolean ca,
00635                            unsigned int nnzb, index2 *bi, float *bc,
00636                            unsigned int *bpermut, int *brows, boolean rb,
00637                            index2 *abi, float *abc );
00638 boolean pkn_SPMmultMTMCf ( int nra, int nca, int ncb,
00639                            unsigned int nnza, index2 *ai, float *ac,
00640                            unsigned int *apermut, int *arows, boolean ra,
00641                            unsigned int nnzb, index2 *bi, float *bc,
00642                            unsigned int *bpermut, int *bcols, boolean cb,
00643                            index2 *abi, float *abc );
00644 
00645 boolean pkn_SPsubMmultMMCf ( int nra, int nca, int ncb,
00646                              unsigned int nnza, index3 *ai, float *ac,
00647                              unsigned int *apermut, int *acols, boolean ca,
00648                              unsigned int nnzb, index3 *bi, float *bc,
00649                              unsigned int *bpermut, int *bcols, boolean cb,
00650                              index2 *abi, float *abc );
00651 boolean pkn_SPsubMmultMMTCf ( int nra, int nca, int nrb,
00652                               unsigned int nnza, index3 *ai, float *ac,
00653                               unsigned int *apermut, int *acols, boolean ca,
00654                               unsigned int nnzb, index3 *bi, float *bc,
00655                               unsigned int *bpermut, int *brows, boolean rb,
00656                               index2 *abi, float *abc );
00657 boolean pkn_SPsubMmultMTMCf ( int nra, int nca, int ncb,
00658                               unsigned int nnza, index3 *ai, float *ac,
00659                               unsigned int *apermut, int *arows, boolean ra,
00660                               unsigned int nnzb, index3 *bi, float *bc,
00661                               unsigned int *bpermut, int *bcols, boolean cb,
00662                               index2 *abi, float *abc );
00663 
00664 /* ///////////////////////////////////////////////////////////////////////// */
00665 boolean pkn_QuadRectanglesf ( float a, float b, int n,
00666                               float *qknots, float *qcoeff );
00667 boolean pkn_QuadSimpsonf ( float a, float b, int n,
00668                            float *qknots, float *qcoeff );
00669 
00670 boolean pkn_QuadGaussLegendre4f ( float a, float b, int n,
00671                                   float *qknots, float *qcoeff );
00672 boolean pkn_QuadGaussLegendre6f ( float a, float b, int n,
00673                                   float *qknots, float *qcoeff );
00674 boolean pkn_QuadGaussLegendre8f ( float a, float b, int n,
00675                                   float *qknots, float *qcoeff );
00676 boolean pkn_QuadGaussLegendre10f ( float a, float b, int n,
00677                                    float *qknots, float *qcoeff );
00678 boolean pkn_QuadGaussLegendre12f ( float a, float b, int n,
00679                                    float *qknots, float *qcoeff );
00680 boolean pkn_QuadGaussLegendre14f ( float a, float b, int n,
00681                                    float *qknots, float *qcoeff );
00682 boolean pkn_QuadGaussLegendre16f ( float a, float b, int n,
00683                                    float *qknots, float *qcoeff );
00684 boolean pkn_QuadGaussLegendre18f ( float a, float b, int n,
00685                                    float *qknots, float *qcoeff );
00686 boolean pkn_QuadGaussLegendre20f ( float a, float b, int n,
00687                                    float *qknots, float *qcoeff );
00688 
00689 /* ///////////////////////////////////////////////////////////////////////// */
00690 #ifndef PKN_LMT_CONTINUE
00691 /* return values of pkn_NLMIterf */
00692 #define PKN_LMT_ERROR          -1
00693 #define PKN_LMT_CONTINUE_LM     0
00694 #define PKN_LMT_CONTINUE_N      1
00695 #define PKN_LMT_FOUND_MINIMUM   2
00696 #define PKN_LMT_FOUND_ZEROGRAD  3
00697 #define PKN_LMT_FOUND_BARRIER   4
00698 #endif
00699 
00700 typedef boolean (*pkn_NLMTevalfuncf)( int n, void *usrdata,
00701                                       float *x, float *f );
00702 typedef boolean (*pkn_NLMTevalfuncgf)( int n, void *usrdata,
00703                                        float *x, float *f, float *g );
00704 typedef boolean (*pkn_NLMTevalfuncghf)( int n, void *usrdata,
00705                                         float *x, float *f, float *g, float *h );
00706 typedef boolean (*pkn_NLMTtransfuncf)( int n, void *usrdata, float *x );
00707 typedef boolean (*pkn_NLMTtunnelfuncf)( int n, void *usrdata,
00708                                         float *x0, float *x1, boolean *went_out );
00709 
00710 int pkn_NLMIterf ( int n, void *usrdata, float *x,
00711                    pkn_NLMTevalfuncf funcf, pkn_NLMTevalfuncgf funcfg,
00712                    pkn_NLMTevalfuncghf funcfgh,
00713                    pkn_NLMTtransfuncf trans, pkn_NLMTtunnelfuncf tunnel,
00714                    float lowerbound, float eps, float delta,
00715                    float *nu );
00716 
00717 #ifdef __cplusplus
00718 }
00719 #endif
00720 
00721 #endif /* PKNUMF_H*/
00722