libcm is a C development framework with an emphasis on audio signal processing applications.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. VECT_OP_TYPE* VECT_OP_FUNC(Col)( VECT_OP_TYPE* m, unsigned ci, unsigned rn, unsigned cn );
  2. VECT_OP_TYPE* VECT_OP_FUNC(Row)( VECT_OP_TYPE* m, unsigned ri, unsigned rn, unsigned cn );
  3. VECT_OP_TYPE* VECT_OP_FUNC(ElePtr)( VECT_OP_TYPE* m, unsigned ri, unsigned ci, unsigned rn, unsigned cn );
  4. VECT_OP_TYPE VECT_OP_FUNC(Ele)( VECT_OP_TYPE* m, unsigned ri, unsigned ci, unsigned rn, unsigned cn );
  5. void VECT_OP_FUNC(Set)( VECT_OP_TYPE* m, unsigned ri, unsigned ci, unsigned rn, unsigned cn, VECT_OP_TYPE v );
  6. const VECT_OP_TYPE* VECT_OP_FUNC(CCol)( const VECT_OP_TYPE* m, unsigned ci, unsigned rn, unsigned cn );
  7. const VECT_OP_TYPE* VECT_OP_FUNC(CRow)( const VECT_OP_TYPE* m, unsigned ri, unsigned rn, unsigned cn );
  8. const VECT_OP_TYPE* VECT_OP_FUNC(CElePtr)( const VECT_OP_TYPE* m, unsigned ri, unsigned ci, unsigned rn, unsigned cn );
  9. VECT_OP_TYPE VECT_OP_FUNC(CEle)( const VECT_OP_TYPE* m, unsigned ri, unsigned ci, unsigned rn, unsigned cn );
  10. /// Fill a vector with a value. If value is 0 then the function is accellerated via memset().
  11. VECT_OP_TYPE* VECT_OP_FUNC(Fill)( VECT_OP_TYPE* dbp, unsigned dn, VECT_OP_TYPE value );
  12. // Fill a vector with zeros
  13. VECT_OP_TYPE* VECT_OP_FUNC(Zero)( VECT_OP_TYPE* dbp, unsigned dn );
  14. // analogous to memmove()
  15. VECT_OP_TYPE* VECT_OP_FUNC(Move)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sp );
  16. /// Fill the vector from various sources
  17. VECT_OP_TYPE* VECT_OP_FUNC(Copy)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sp );
  18. VECT_OP_TYPE* VECT_OP_FUNC(CopyN)( VECT_OP_TYPE* dbp, unsigned dn, unsigned d_stride, const VECT_OP_TYPE* sp, unsigned s_stride );
  19. VECT_OP_TYPE* VECT_OP_FUNC(CopyU)( VECT_OP_TYPE* dbp, unsigned dn, const unsigned* sp );
  20. VECT_OP_TYPE* VECT_OP_FUNC(CopyI)( VECT_OP_TYPE* dbp, unsigned dn, const int* sp );
  21. VECT_OP_TYPE* VECT_OP_FUNC(CopyF)( VECT_OP_TYPE* dbp, unsigned dn, const float* sp );
  22. VECT_OP_TYPE* VECT_OP_FUNC(CopyD)( VECT_OP_TYPE* dbp, unsigned dn, const double* sp );
  23. VECT_OP_TYPE* VECT_OP_FUNC(CopyS)( VECT_OP_TYPE* dbp, unsigned dn, const cmSample_t* sp );
  24. VECT_OP_TYPE* VECT_OP_FUNC(CopyR)( VECT_OP_TYPE* dbp, unsigned dn, const cmReal_t* sp );
  25. // Shrink the elemetns of dbp[dn] by copying all elements past t+tn to t.
  26. // This operation results in overwriting the elements in the range t[tn].
  27. // t[tn] must be entirely inside dbp[dn].
  28. VECT_OP_TYPE* VECT_OP_FUNC(Shrink)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* t, unsigned tn );
  29. // Expand dbp[[dn] by shifting all elements past t to t+tn.
  30. // This produces a set of empty elements in t[tn].
  31. // t must be inside or at the end of dbp[dn].
  32. // This results in a reallocation of dbp[]. Be sure to call cmMemFree(dbp)
  33. // to release the returned pointer.
  34. VECT_OP_TYPE* VECT_OP_FUNC(Expand)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* t, unsigned tn );
  35. // Replace the elements t[tn] with the elements in u[un].
  36. // t must be inside or at the end of dbp[dn].
  37. // This operation may result in a reallocation of dbp[]. Be sure to call cmMemFree(dbp)
  38. // to release the returned pointer.
  39. // IF dbp==NULL and tn==0 then the dbp[un] is allocated and returned
  40. // with the contents of u[un].
  41. VECT_OP_TYPE* VECT_OP_FUNC(Replace)(VECT_OP_TYPE* dbp, unsigned* dn, const VECT_OP_TYPE* t, unsigned tn, const VECT_OP_TYPE* u, unsigned un );
  42. /// Fill the the destination vector from a source vector where the source vector contains
  43. /// srcStride interleaved elements to be ignored.
  44. VECT_OP_TYPE* VECT_OP_FUNC(CopyStride)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sp, unsigned srcStride );
  45. /// Assuming a row vector positive shiftCnt rotates right, negative shiftCnt rotates left.
  46. VECT_OP_TYPE* VECT_OP_FUNC(Rotate)( VECT_OP_TYPE* dbp, unsigned dn, int shiftCnt );
  47. /// Equivalent to Matlab circshift().
  48. VECT_OP_TYPE* VECT_OP_FUNC(RotateM)( VECT_OP_TYPE* dbp, unsigned drn, unsigned dcn, const VECT_OP_TYPE* sbp, int rShift, int cShift );
  49. /// Assuming a row vector positive shiftCnt shifts right, negative shiftCnt shifts left.
  50. VECT_OP_TYPE* VECT_OP_FUNC(Shift)( VECT_OP_TYPE* dbp, unsigned dn, int shiftCnt, VECT_OP_TYPE fill );
  51. /// Reverse the contents of the vector.
  52. VECT_OP_TYPE* VECT_OP_FUNC(Flip)( VECT_OP_TYPE* dbp, unsigned dn);
  53. VECT_OP_TYPE* VECT_OP_FUNC(SubVS)( VECT_OP_TYPE* dp, unsigned dn, VECT_OP_TYPE v );
  54. VECT_OP_TYPE* VECT_OP_FUNC(SubVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* v );
  55. VECT_OP_TYPE* VECT_OP_FUNC(SubVVS)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* v, VECT_OP_TYPE s );
  56. VECT_OP_TYPE* VECT_OP_FUNC(SubVVNN)(VECT_OP_TYPE* dp, unsigned dn, unsigned dnn, const VECT_OP_TYPE* sp, unsigned snn );
  57. VECT_OP_TYPE* VECT_OP_FUNC(SubVVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
  58. VECT_OP_TYPE* VECT_OP_FUNC(SubVSV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE s0, const VECT_OP_TYPE* sb1p );
  59. VECT_OP_TYPE* VECT_OP_FUNC(AddVS)( VECT_OP_TYPE* dp, unsigned dn, VECT_OP_TYPE v );
  60. VECT_OP_TYPE* VECT_OP_FUNC(AddVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* v );
  61. VECT_OP_TYPE* VECT_OP_FUNC(AddVVS)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* v, VECT_OP_TYPE s );
  62. VECT_OP_TYPE* VECT_OP_FUNC(AddVVNN)(VECT_OP_TYPE* dp, unsigned dn, unsigned dnn, const VECT_OP_TYPE* sp, unsigned snn );
  63. VECT_OP_TYPE* VECT_OP_FUNC(AddVVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
  64. VECT_OP_TYPE* VECT_OP_FUNC(MultVVV)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
  65. VECT_OP_TYPE* VECT_OP_FUNC(MultVV)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp );
  66. VECT_OP_TYPE* VECT_OP_FUNC(MultVVNN)(VECT_OP_TYPE* dp, unsigned dn, unsigned dnn, const VECT_OP_TYPE* sp, unsigned snn );
  67. VECT_OP_TYPE* VECT_OP_FUNC(MultVS)( VECT_OP_TYPE* dbp, unsigned dn, VECT_OP_TYPE s );
  68. VECT_OP_TYPE* VECT_OP_FUNC(MultVVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp, VECT_OP_TYPE s );
  69. VECT_OP_TYPE* VECT_OP_FUNC(MultVaVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp, VECT_OP_TYPE s );
  70. VECT_OP_TYPE* VECT_OP_FUNC(MultSumVVS)(VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp, VECT_OP_TYPE s );
  71. VECT_OP_TYPE* VECT_OP_FUNC(DivVVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, VECT_OP_TYPE sb1 );
  72. VECT_OP_TYPE* VECT_OP_FUNC(DivVVV)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
  73. VECT_OP_TYPE* VECT_OP_FUNC(DivVV)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p );
  74. VECT_OP_TYPE* VECT_OP_FUNC(DivVVNN)(VECT_OP_TYPE* dp, unsigned dn, unsigned dnn, const VECT_OP_TYPE* sp, unsigned snn );
  75. VECT_OP_TYPE* VECT_OP_FUNC(DivVS)( VECT_OP_TYPE* dbp, unsigned dn, VECT_OP_TYPE s );
  76. VECT_OP_TYPE* VECT_OP_FUNC(DivVSV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE s0, const VECT_OP_TYPE* sb1p );
  77. // Set dest to 0 if denominator is 0.
  78. VECT_OP_TYPE* VECT_OP_FUNC(DivVVVZ)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
  79. VECT_OP_TYPE* VECT_OP_FUNC(DivVVZ)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p );
  80. // Divide columns of dp[:,i] by each value in the source vector sp[i].
  81. VECT_OP_TYPE* VECT_OP_FUNC(DivMS)( VECT_OP_TYPE* dp, unsigned drn, unsigned dcn, const VECT_OP_TYPE* sp );
  82. VECT_OP_TYPE VECT_OP_FUNC(Sum)( const VECT_OP_TYPE* sp, unsigned sn );
  83. VECT_OP_TYPE VECT_OP_FUNC(SumN)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  84. // Sum the columns of sp[srn,scn] into dp[scn].
  85. // dp[] is zeroed prior to computing the sum.
  86. VECT_OP_TYPE* VECT_OP_FUNC(SumM)( const VECT_OP_TYPE* sp, unsigned srn, unsigned scn, VECT_OP_TYPE* dp );
  87. // Sum the rows of sp[srn,scn] into dp[srn]
  88. // dp[] is zeroed prior to computing the sum.
  89. VECT_OP_TYPE* VECT_OP_FUNC(SumMN)( const VECT_OP_TYPE* sp, unsigned srn, unsigned scn, VECT_OP_TYPE* dp );
  90. VECT_OP_TYPE* VECT_OP_FUNC(Abs)( VECT_OP_TYPE* dbp, unsigned dn );
  91. VECT_OP_TYPE VECT_OP_FUNC(Median)( const VECT_OP_TYPE* sp, unsigned sn );
  92. unsigned VECT_OP_FUNC(MinIndex)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  93. unsigned VECT_OP_FUNC(MaxIndex)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  94. VECT_OP_TYPE VECT_OP_FUNC(Min)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  95. VECT_OP_TYPE VECT_OP_FUNC(Max)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  96. VECT_OP_TYPE* VECT_OP_FUNC(MinVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* sp );
  97. VECT_OP_TYPE* VECT_OP_FUNC(MaxVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* sp );
  98. /// Return index of max/min value into dp[scn] of each column of sp[srn,scn]
  99. unsigned* VECT_OP_FUNC(MinIndexM)( unsigned* dp, const VECT_OP_TYPE* sp, unsigned srn, unsigned scn );
  100. unsigned* VECT_OP_FUNC(MaxIndexM)( unsigned* dp, const VECT_OP_TYPE* sp, unsigned srn, unsigned scn );
  101. /// Return true if s0p[sn] is equal to s1p[sn]
  102. bool VECT_OP_FUNC(IsEqual)( const VECT_OP_TYPE* s0p, const VECT_OP_TYPE* s1p, unsigned sn );
  103. /// Return true if all elements of s0p[sn] are within 'eps' of s1p[sn].
  104. /// This function is based on cmMath.h:cmIsCloseX()
  105. bool VECT_OP_FUNC(IsClose)( const VECT_OP_TYPE* s0p, const VECT_OP_TYPE* s1p, unsigned sn, double eps );
  106. /// Return the most frequently occuring element in sp.
  107. VECT_OP_TYPE VECT_OP_FUNC(Mode)( const VECT_OP_TYPE* sp, unsigned sn );
  108. /// Replace all values <= lteKeyVal with replaceVal. sp==dp is legal.
  109. VECT_OP_TYPE* VECT_OP_FUNC(ReplaceLte)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* sp, VECT_OP_TYPE lteKeyVal, VECT_OP_TYPE replaceVal );
  110. /// Return the index of 'key' in sp[sn] or cmInvalidIdx if 'key' does not exist.
  111. unsigned VECT_OP_FUNC(Find)( const VECT_OP_TYPE* sp, unsigned sn, VECT_OP_TYPE key );
  112. /// Count the number of times 'key' occurs in sp[sn].
  113. unsigned VECT_OP_FUNC(Count)(const VECT_OP_TYPE* sp, unsigned sn, VECT_OP_TYPE key );
  114. /// Set only the diagonal of a square mtx to sbp.
  115. VECT_OP_TYPE* VECT_OP_FUNC(Diag)( VECT_OP_TYPE* dbp, unsigned n, const VECT_OP_TYPE* sbp );
  116. /// Set the diagonal of a square mtx to db to sbp and set all other values to zero.
  117. VECT_OP_TYPE* VECT_OP_FUNC(DiagZ)( VECT_OP_TYPE* dbp, unsigned n, const VECT_OP_TYPE* sbp );
  118. /// Create an identity matrix (only sets 1's not zeros).
  119. VECT_OP_TYPE* VECT_OP_FUNC(Identity)( VECT_OP_TYPE* dbp, unsigned rn, unsigned cn );
  120. /// Zero the matrix and then fill it as an identity matrix.
  121. VECT_OP_TYPE* VECT_OP_FUNC(IdentityZ)( VECT_OP_TYPE* dbp, unsigned rn, unsigned cn );
  122. /// Transpose the matrix sbp[srn,scn] into dbp[scn,srn]
  123. VECT_OP_TYPE* VECT_OP_FUNC(Transpose)( VECT_OP_TYPE* dbp, const VECT_OP_TYPE* sbp, unsigned srn, unsigned scn );
  124. /// Fill dbp[] with a sequence of values. Returns next value.
  125. VECT_OP_TYPE VECT_OP_FUNC(Seq)( VECT_OP_TYPE* dbp, unsigned dn, VECT_OP_TYPE beg, VECT_OP_TYPE incr );
  126. /// Apply a median or other filter of order wndN to xV[xN] and store the result in yV[xN].
  127. /// When the window goes off either side of the vector the window is shortened.
  128. /// This algorithm produces the same result as the fn_thresh function in MATLAB fv codebase.
  129. void VECT_OP_FUNC(FnThresh)( const VECT_OP_TYPE* xV, unsigned xN, unsigned wndN, VECT_OP_TYPE* yV, unsigned yStride, VECT_OP_TYPE (*fnPtr)(const VECT_OP_TYPE*, unsigned) );
  130. /// Apply a median filter of order wndN to xV[xN] and store the result in yV[xN].
  131. /// When the window goes off either side of the vector the missing elements are considered
  132. /// to be 0.
  133. /// This algorithm produces the same result as the MATLAB medfilt1() function.
  134. void VECT_OP_FUNC(MedianFilt)( const VECT_OP_TYPE* xV, unsigned xN, unsigned wndN, VECT_OP_TYPE* yV, unsigned yStride );
  135. /// Allocate and initialize a matrix for use by LevEditDist().
  136. /// This matrix can be released with a call to cmMemFree().
  137. unsigned* VECT_OP_FUNC(LevEditDistAllocMtx)(unsigned mtxMaxN);
  138. /// Return the Levenshtein edit distance between two vectors.
  139. /// m must point to a matrix pre-allocated by VECT_OP_FUNC(InitiLevEditDistMtx)(maxN).
  140. double VECT_OP_FUNC(LevEditDist)(unsigned mtxMaxN, unsigned* m, const VECT_OP_TYPE* s0, int n0, const VECT_OP_TYPE* s1, int n1, unsigned maxN );
  141. /// Return the Levenshtein edit distance between two vectors.
  142. /// Edit distance with a max cost threshold. This version of the algorithm
  143. /// will run faster than LevEditDist() because it will stop execution as soon
  144. /// as the distance exceeds 'maxCost'.
  145. /// 'maxCost' must be between 0.0 and 1.0 or it is forced into this range.
  146. /// The maximum distance returned will be 'maxCost'.
  147. /// m must point to a matrix pre-allocated by VECT_OP_FUNC(InitiLevEditDistMtx)(maxN).
  148. double VECT_OP_FUNC(LevEditDistWithCostThresh)( int mtxMaxN, unsigned* m, const VECT_OP_TYPE* s0, int n0, const VECT_OP_TYPE* s1, int n1, double maxCost, unsigned maxN );