libcm is a C development framework with an emphasis on audio signal processing applications.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

cmVectOpsRIHdr.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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(DivVVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, VECT_OP_TYPE sb1 );
  71. VECT_OP_TYPE* VECT_OP_FUNC(DivVVV)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
  72. VECT_OP_TYPE* VECT_OP_FUNC(DivVV)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p );
  73. VECT_OP_TYPE* VECT_OP_FUNC(DivVVNN)(VECT_OP_TYPE* dp, unsigned dn, unsigned dnn, const VECT_OP_TYPE* sp, unsigned snn );
  74. VECT_OP_TYPE* VECT_OP_FUNC(DivVS)( VECT_OP_TYPE* dbp, unsigned dn, VECT_OP_TYPE s );
  75. VECT_OP_TYPE* VECT_OP_FUNC(DivVSV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE s0, const VECT_OP_TYPE* sb1p );
  76. // Set dest to 0 if denominator is 0.
  77. VECT_OP_TYPE* VECT_OP_FUNC(DivVVVZ)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
  78. VECT_OP_TYPE* VECT_OP_FUNC(DivVVZ)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p );
  79. // Divide columns of dp[:,i] by each value in the source vector sp[i].
  80. VECT_OP_TYPE* VECT_OP_FUNC(DivMS)( VECT_OP_TYPE* dp, unsigned drn, unsigned dcn, const VECT_OP_TYPE* sp );
  81. VECT_OP_TYPE VECT_OP_FUNC(Sum)( const VECT_OP_TYPE* sp, unsigned sn );
  82. VECT_OP_TYPE VECT_OP_FUNC(SumN)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  83. // Sum the columns of sp[srn,scn] into dp[scn].
  84. // dp[] is zeroed prior to computing the sum.
  85. VECT_OP_TYPE* VECT_OP_FUNC(SumM)( const VECT_OP_TYPE* sp, unsigned srn, unsigned scn, VECT_OP_TYPE* dp );
  86. // Sum the rows of sp[srn,scn] into dp[srn]
  87. // dp[] is zeroed prior to computing the sum.
  88. VECT_OP_TYPE* VECT_OP_FUNC(SumMN)( const VECT_OP_TYPE* sp, unsigned srn, unsigned scn, VECT_OP_TYPE* dp );
  89. VECT_OP_TYPE* VECT_OP_FUNC(Abs)( VECT_OP_TYPE* dbp, unsigned dn );
  90. VECT_OP_TYPE VECT_OP_FUNC(Median)( const VECT_OP_TYPE* sp, unsigned sn );
  91. unsigned VECT_OP_FUNC(MinIndex)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  92. unsigned VECT_OP_FUNC(MaxIndex)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  93. VECT_OP_TYPE VECT_OP_FUNC(Min)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  94. VECT_OP_TYPE VECT_OP_FUNC(Max)( const VECT_OP_TYPE* sp, unsigned sn, unsigned stride );
  95. VECT_OP_TYPE* VECT_OP_FUNC(MinVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* sp );
  96. VECT_OP_TYPE* VECT_OP_FUNC(MaxVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* sp );
  97. /// Return index of max/min value into dp[scn] of each column of sp[srn,scn]
  98. unsigned* VECT_OP_FUNC(MinIndexM)( unsigned* dp, const VECT_OP_TYPE* sp, unsigned srn, unsigned scn );
  99. unsigned* VECT_OP_FUNC(MaxIndexM)( unsigned* dp, const VECT_OP_TYPE* sp, unsigned srn, unsigned scn );
  100. /// Return the most frequently occuring element in sp.
  101. VECT_OP_TYPE VECT_OP_FUNC(Mode)( const VECT_OP_TYPE* sp, unsigned sn );
  102. /// Replace all values <= lteKeyVal with replaceVal. sp==dp is legal.
  103. 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 );
  104. /// Return the index of 'key' in sp[sn] or cmInvalidIdx if 'key' does not exist.
  105. unsigned VECT_OP_FUNC(Find)( const VECT_OP_TYPE* sp, unsigned sn, VECT_OP_TYPE key );
  106. /// Count the number of times 'key' occurs in sp[sn].
  107. unsigned VECT_OP_FUNC(Count)(const VECT_OP_TYPE* sp, unsigned sn, VECT_OP_TYPE key );
  108. /// Set only the diagonal of a square mtx to sbp.
  109. VECT_OP_TYPE* VECT_OP_FUNC(Diag)( VECT_OP_TYPE* dbp, unsigned n, const VECT_OP_TYPE* sbp );
  110. /// Set the diagonal of a square mtx to db to sbp and set all other values to zero.
  111. VECT_OP_TYPE* VECT_OP_FUNC(DiagZ)( VECT_OP_TYPE* dbp, unsigned n, const VECT_OP_TYPE* sbp );
  112. /// Create an identity matrix (only sets 1's not zeros).
  113. VECT_OP_TYPE* VECT_OP_FUNC(Identity)( VECT_OP_TYPE* dbp, unsigned rn, unsigned cn );
  114. /// Zero the matrix and then fill it as an identity matrix.
  115. VECT_OP_TYPE* VECT_OP_FUNC(IdentityZ)( VECT_OP_TYPE* dbp, unsigned rn, unsigned cn );
  116. /// Transpose the matrix sbp[srn,scn] into dbp[scn,srn]
  117. VECT_OP_TYPE* VECT_OP_FUNC(Transpose)( VECT_OP_TYPE* dbp, const VECT_OP_TYPE* sbp, unsigned srn, unsigned scn );
  118. /// Fill dbp[] with a sequence of values. Returns next value.
  119. VECT_OP_TYPE VECT_OP_FUNC(Seq)( VECT_OP_TYPE* dbp, unsigned dn, VECT_OP_TYPE beg, VECT_OP_TYPE incr );
  120. /// Apply a median or other filter of order wndN to xV[xN] and store the result in yV[xN].
  121. /// When the window goes off either side of the vector the window is shortened.
  122. /// This algorithm produces the same result as the fn_thresh function in MATLAB fv codebase.
  123. 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) );
  124. /// Apply a median filter of order wndN to xV[xN] and store the result in yV[xN].
  125. /// When the window goes off either side of the vector the missing elements are considered
  126. /// to be 0.
  127. /// This algorithm produces the same result as the MATLAB medfilt1() function.
  128. void VECT_OP_FUNC(MedianFilt)( const VECT_OP_TYPE* xV, unsigned xN, unsigned wndN, VECT_OP_TYPE* yV, unsigned yStride );
  129. /// Allocate and initialize a matrix for use by LevEditDist().
  130. /// This matrix can be released with a call to cmMemFree().
  131. unsigned* VECT_OP_FUNC(LevEditDistAllocMtx)(unsigned mtxMaxN);
  132. /// Return the Levenshtein edit distance between two vectors.
  133. /// m must point to a matrix pre-allocated by VECT_OP_FUNC(InitiLevEditDistMtx)(maxN).
  134. 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 );
  135. /// Return the Levenshtein edit distance between two vectors.
  136. /// Edit distance with a max cost threshold. This version of the algorithm
  137. /// will run faster than LevEditDist() because it will stop execution as soon
  138. /// as the distance exceeds 'maxCost'.
  139. /// 'maxCost' must be between 0.0 and 1.0 or it is forced into this range.
  140. /// The maximum distance returned will be 'maxCost'.
  141. /// m must point to a matrix pre-allocated by VECT_OP_FUNC(InitiLevEditDistMtx)(maxN).
  142. 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 );