/svdlib/svdutil.h

https://github.com/amumu/divisi2 · C Header · 121 lines · 28 code · 25 blank · 68 comment · 0 complexity · 1d1636b36a759e5392c53c42f43b16a4 MD5 · raw file

  1. #ifndef SVDUTIL_H
  2. #define SVDUTIL_H
  3. #include "svdlib.h"
  4. #define SAFE_FREE(a) {if (a) {free(a); a = NULL;}}
  5. /* Allocates an array of longs. */
  6. extern long *svd_longArray(long size, char empty, const char *name);
  7. /* Allocates an array of doubles. */
  8. extern double *svd_doubleArray(long size, char empty, const char *name);
  9. extern void svd_debug(char *fmt, ...);
  10. extern void svd_error(char *fmt, ...);
  11. extern void svd_fatalError(char *fmt, ...);
  12. /**************************************************************
  13. * returns |a| if b is positive; else fsign returns -|a| *
  14. **************************************************************/
  15. extern double svd_fsign(double a, double b);
  16. /**************************************************************
  17. * returns the larger of two double precision numbers *
  18. **************************************************************/
  19. extern double svd_dmax(double a, double b);
  20. /**************************************************************
  21. * returns the smaller of two double precision numbers *
  22. **************************************************************/
  23. extern double svd_dmin(double a, double b);
  24. /**************************************************************
  25. * returns the larger of two integers *
  26. **************************************************************/
  27. extern long svd_imax(long a, long b);
  28. /**************************************************************
  29. * returns the smaller of two integers *
  30. **************************************************************/
  31. extern long svd_imin(long a, long b);
  32. /**************************************************************
  33. * Function scales a vector by a constant. *
  34. * Based on Fortran-77 routine from Linpack by J. Dongarra *
  35. **************************************************************/
  36. extern void svd_dscal(long n, double da, double *dx, long incx);
  37. /**************************************************************
  38. * function scales a vector by a constant. *
  39. * Based on Fortran-77 routine from Linpack by J. Dongarra *
  40. **************************************************************/
  41. extern void svd_datx(long n, double da, double *dx, long incx, double *dy, long incy);
  42. /**************************************************************
  43. * Function copies a vector x to a vector y *
  44. * Based on Fortran-77 routine from Linpack by J. Dongarra *
  45. **************************************************************/
  46. extern void svd_dcopy(long n, double *dx, long incx, double *dy, long incy);
  47. /**************************************************************
  48. * Function forms the dot product of two vectors. *
  49. * Based on Fortran-77 routine from Linpack by J. Dongarra *
  50. **************************************************************/
  51. extern double svd_ddot(long n, double *dx, long incx, double *dy, long incy);
  52. /**************************************************************
  53. * Constant times a vector plus a vector *
  54. * Based on Fortran-77 routine from Linpack by J. Dongarra *
  55. **************************************************************/
  56. extern void svd_daxpy (long n, double da, double *dx, long incx, double *dy, long incy);
  57. /*********************************************************************
  58. * Function sorts array1 and array2 into increasing order for array1 *
  59. *********************************************************************/
  60. extern void svd_dsort2(long igap, long n, double *array1, double *array2);
  61. /**************************************************************
  62. * Function interchanges two vectors *
  63. * Based on Fortran-77 routine from Linpack by J. Dongarra *
  64. **************************************************************/
  65. extern void svd_dswap(long n, double *dx, long incx, double *dy, long incy);
  66. /*****************************************************************
  67. * Function finds the index of element having max. absolute value*
  68. * based on FORTRAN 77 routine from Linpack by J. Dongarra *
  69. *****************************************************************/
  70. extern long svd_idamax(long n, double *dx, long incx);
  71. /**************************************************************
  72. * multiplication of matrix B by vector x, where B = A'A, *
  73. * and A is nrow by ncol (nrow >> ncol). Hence, B is of order *
  74. * n = ncol (y stores product vector). *
  75. **************************************************************/
  76. extern void svd_opb(SMat A, double *x, double *y, double *temp);
  77. /***********************************************************
  78. * multiplication of matrix A by vector x, where A is *
  79. * nrow by ncol (nrow >> ncol). y stores product vector. *
  80. ***********************************************************/
  81. extern void svd_opa(SMat A, double *x, double *y);
  82. void mat_transposed_by_vec(SMat A, double *x, double *out);
  83. /***********************************************************************
  84. * *
  85. * random2() *
  86. * (double precision) *
  87. ***********************************************************************/
  88. extern double svd_random2(long *iy);
  89. /**************************************************************
  90. * *
  91. * Function finds sqrt(a^2 + b^2) without overflow or *
  92. * destructive underflow. *
  93. * *
  94. **************************************************************/
  95. extern double svd_pythag(double a, double b);
  96. #endif /* SVDUTIL_H */