PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/ATLAS/src/blas/reference/level1/ATL_srefasum.c

https://github.com/hihihippp/Kaldi
C | 133 lines | 43 code | 6 blank | 84 comment | 7 complexity | bf02da9ea6abeb09e83af651beff6d50 MD5 | raw file
Possible License(s): Apache-2.0
  1. /* ---------------------------------------------------------------------
  2. *
  3. * -- Automatically Tuned Linear Algebra Software (ATLAS)
  4. * (C) Copyright 2000 All Rights Reserved
  5. *
  6. * -- ATLAS routine -- Version 3.9.24 -- December 25, 2000
  7. *
  8. * Author : Antoine P. Petitet
  9. * Originally developed at the University of Tennessee,
  10. * Innovative Computing Laboratory, Knoxville TN, 37996-1301, USA.
  11. *
  12. * ---------------------------------------------------------------------
  13. *
  14. * -- Copyright notice and Licensing terms:
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions
  18. * are met:
  19. *
  20. * 1. Redistributions of source code must retain the above copyright
  21. * notice, this list of conditions and the following disclaimer.
  22. * 2. Redistributions in binary form must reproduce the above copyright
  23. * notice, this list of conditions, and the following disclaimer in
  24. * the documentation and/or other materials provided with the distri-
  25. * bution.
  26. * 3. The name of the University, the ATLAS group, or the names of its
  27. * contributors may not be used to endorse or promote products deri-
  28. * ved from this software without specific written permission.
  29. *
  30. * -- Disclaimer:
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  33. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  34. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  35. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
  36. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
  37. * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  38. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  39. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEO-
  40. * RY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (IN-
  41. * CLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  42. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  43. *
  44. * ---------------------------------------------------------------------
  45. */
  46. /*
  47. * Include files
  48. */
  49. #include "atlas_refmisc.h"
  50. #include "atlas_reflevel1.h"
  51. float ATL_srefasum
  52. (
  53. const int N,
  54. const float * X,
  55. const int INCX
  56. )
  57. {
  58. /*
  59. * Purpose
  60. * =======
  61. *
  62. * ATL_srefasum returns the sum of absolute values of the entries of a
  63. * vector x.
  64. *
  65. * Arguments
  66. * =========
  67. *
  68. * N (input) const int
  69. * On entry, N specifies the length of the vector x. N must be
  70. * at least zero. Unchanged on exit.
  71. *
  72. * X (input) const float *
  73. * On entry, X points to the first entry to be accessed of an
  74. * incremented array of size equal to or greater than
  75. * ( 1 + ( n - 1 ) * abs( INCX ) ) * sizeof( float ),
  76. * that contains the vector x. Unchanged on exit.
  77. *
  78. * INCX (input) const int
  79. * On entry, INCX specifies the increment for the elements of X.
  80. * INCX must not be zero. Unchanged on exit.
  81. *
  82. * ---------------------------------------------------------------------
  83. */
  84. /*
  85. * .. Local Variables ..
  86. */
  87. register float sum = ATL_sZERO, x0, x1, x2, x3,
  88. x4, x5, x6, x7;
  89. float * StX;
  90. register int i;
  91. int nu;
  92. const int incX2 = 2 * INCX, incX3 = 3 * INCX,
  93. incX4 = 4 * INCX, incX5 = 5 * INCX,
  94. incX6 = 6 * INCX, incX7 = 7 * INCX,
  95. incX8 = 8 * INCX;
  96. /* ..
  97. * .. Executable Statements ..
  98. *
  99. */
  100. if( ( N > 0 ) && ( INCX >= 1 ) )
  101. {
  102. if( ( nu = ( N >> 3 ) << 3 ) != 0 )
  103. {
  104. StX = (float *)X + nu * INCX;
  105. do
  106. {
  107. x0 = (*X); x4 = X[incX4]; x1 = X[INCX ]; x5 = X[incX5];
  108. x2 = X[incX2]; x6 = X[incX6]; x3 = X[incX3]; x7 = X[incX7];
  109. sum += Msabs( x0 ); sum += Msabs( x4 );
  110. sum += Msabs( x1 ); sum += Msabs( x3 );
  111. sum += Msabs( x2 ); sum += Msabs( x6 );
  112. sum += Msabs( x5 ); sum += Msabs( x7 );
  113. X += incX8;
  114. } while( X != StX );
  115. }
  116. for( i = N - nu; i != 0; i-- )
  117. {
  118. x0 = (*X);
  119. sum += Msabs( x0 );
  120. X += INCX;
  121. }
  122. }
  123. return( sum );
  124. /*
  125. * End of ATL_srefasum
  126. */
  127. }