File size: 14,634 Bytes
9375c9a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
<html><!-- Created using the cpp_pretty_printer from the dlib C++ library. See http://dlib.net for updates. --><head><title>dlib C++ Library - cblas_chemv.c</title></head><body bgcolor='white'><pre>
<font color='#009900'>/*
* cblas_chemv.c
* The program is a C interface to chemv
*
* Keita Teranishi 5/18/98
*
*/</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'><</font>stdio.h<font color='#5555FF'>></font>
<font color='#0000FF'>#include</font> <font color='#5555FF'><</font>stdlib.h<font color='#5555FF'>></font>
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='cblas.h.html'>cblas.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='cblas_f77.h.html'>cblas_f77.h</a>"
<font color='#0000FF'><u>void</u></font> <b><a name='cblas_chemv'></a>cblas_chemv</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> <font color='#0000FF'>enum</font> CBLAS_ORDER order,
<font color='#0000FF'>const</font> <font color='#0000FF'>enum</font> CBLAS_UPLO Uplo, <font color='#0000FF'>const</font> CBLAS_INT_TYPE N,
<font color='#0000FF'>const</font> <font color='#0000FF'><u>void</u></font> <font color='#5555FF'>*</font>alpha, <font color='#0000FF'>const</font> <font color='#0000FF'><u>void</u></font> <font color='#5555FF'>*</font>A, <font color='#0000FF'>const</font> CBLAS_INT_TYPE lda,
<font color='#0000FF'>const</font> <font color='#0000FF'><u>void</u></font> <font color='#5555FF'>*</font>X, <font color='#0000FF'>const</font> CBLAS_INT_TYPE incX, <font color='#0000FF'>const</font> <font color='#0000FF'><u>void</u></font> <font color='#5555FF'>*</font>beta,
<font color='#0000FF'><u>void</u></font> <font color='#5555FF'>*</font>Y, <font color='#0000FF'>const</font> CBLAS_INT_TYPE incY<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'><u>char</u></font> UL;
<font color='#0000FF'>#ifdef</font> F77_CHAR
F77_CHAR F77_UL;
<font color='#0000FF'>#else</font>
<font color='#0000FF'>#define</font> F77_UL <font color='#5555FF'>&</font>UL
<font color='#0000FF'>#endif</font>
<font color='#0000FF'>#ifdef</font> F77_INT
F77_INT F77_N<font color='#5555FF'>=</font>N, F77_lda<font color='#5555FF'>=</font>lda, F77_incX<font color='#5555FF'>=</font>incX, F77_incY<font color='#5555FF'>=</font>incY;
<font color='#0000FF'>#else</font>
<font color='#0000FF'>#define</font> F77_N N
<font color='#0000FF'>#define</font> F77_lda lda
<font color='#0000FF'>#define</font> F77_incX incx
<font color='#0000FF'>#define</font> F77_incY incY
<font color='#0000FF'>#endif</font>
CBLAS_INT_TYPE n<font color='#5555FF'>=</font><font color='#979000'>0</font>, i<font color='#5555FF'>=</font><font color='#979000'>0</font>, incx<font color='#5555FF'>=</font>incX;
<font color='#0000FF'>const</font> <font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font>xx<font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font><font face='Lucida Console'>)</font>X, <font color='#5555FF'>*</font>alp<font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font><font face='Lucida Console'>)</font>alpha, <font color='#5555FF'>*</font>bet <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font><font face='Lucida Console'>)</font>beta;
<font color='#0000FF'><u>float</u></font> ALPHA[<font color='#979000'>2</font>],BETA[<font color='#979000'>2</font>];
CBLAS_INT_TYPE tincY, tincx;
<font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font>x<font color='#5555FF'>=</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font><font face='Lucida Console'>)</font>X, <font color='#5555FF'>*</font>y<font color='#5555FF'>=</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font><font face='Lucida Console'>)</font>Y, <font color='#5555FF'>*</font>st<font color='#5555FF'>=</font><font color='#979000'>0</font>, <font color='#5555FF'>*</font>tx;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>order <font color='#5555FF'>=</font><font color='#5555FF'>=</font> CblasColMajor<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Uplo <font color='#5555FF'>=</font><font color='#5555FF'>=</font> CblasUpper<font face='Lucida Console'>)</font> UL <font color='#5555FF'>=</font> '<font color='#FF0000'>U</font>';
<font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Uplo <font color='#5555FF'>=</font><font color='#5555FF'>=</font> CblasLower<font face='Lucida Console'>)</font> UL <font color='#5555FF'>=</font> '<font color='#FF0000'>L</font>';
<font color='#0000FF'>else</font>
<b>{</b>
<font color='#BB00BB'>cblas_xerbla</font><font face='Lucida Console'>(</font><font color='#979000'>2</font>, "<font color='#CC0000'>cblas_chemv</font>","<font color='#CC0000'>Illegal Uplo setting, %d\n</font>",Uplo <font face='Lucida Console'>)</font>;
<font color='#0000FF'>return</font>;
<b>}</b>
<font color='#0000FF'>#ifdef</font> F77_CHAR
F77_UL <font color='#5555FF'>=</font> <font color='#BB00BB'>C2F_CHAR</font><font face='Lucida Console'>(</font><font color='#5555FF'>&</font>UL<font face='Lucida Console'>)</font>;
<font color='#0000FF'>#endif</font>
<font color='#BB00BB'>F77_chemv</font><font face='Lucida Console'>(</font>F77_UL, <font color='#5555FF'>&</font>F77_N, alpha, A, <font color='#5555FF'>&</font>F77_lda, X, <font color='#5555FF'>&</font>F77_incX,
beta, Y, <font color='#5555FF'>&</font>F77_incY<font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>order <font color='#5555FF'>=</font><font color='#5555FF'>=</font> CblasRowMajor<font face='Lucida Console'>)</font>
<b>{</b>
ALPHA[<font color='#979000'>0</font>]<font color='#5555FF'>=</font> <font color='#5555FF'>*</font>alp;
ALPHA[<font color='#979000'>1</font>]<font color='#5555FF'>=</font> <font color='#5555FF'>-</font>alp[<font color='#979000'>1</font>];
BETA[<font color='#979000'>0</font>]<font color='#5555FF'>=</font> <font color='#5555FF'>*</font>bet;
BETA[<font color='#979000'>1</font>]<font color='#5555FF'>=</font> <font color='#5555FF'>-</font>bet[<font color='#979000'>1</font>];
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>N <font color='#5555FF'>></font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
<b>{</b>
n <font color='#5555FF'>=</font> N <font color='#5555FF'><</font><font color='#5555FF'><</font> <font color='#979000'>1</font>;
x <font color='#5555FF'>=</font> <font color='#BB00BB'>malloc</font><font face='Lucida Console'>(</font>n<font color='#5555FF'>*</font><font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>float</u></font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
tx <font color='#5555FF'>=</font> x;
<font color='#0000FF'>if</font><font face='Lucida Console'>(</font> incX <font color='#5555FF'>></font> <font color='#979000'>0</font> <font face='Lucida Console'>)</font> <b>{</b>
i <font color='#5555FF'>=</font> incX <font color='#5555FF'><</font><font color='#5555FF'><</font> <font color='#979000'>1</font> ;
tincx <font color='#5555FF'>=</font> <font color='#979000'>2</font>;
st<font color='#5555FF'>=</font> x<font color='#5555FF'>+</font>n;
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
i <font color='#5555FF'>=</font> incX <font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font color='#5555FF'>-</font><font color='#979000'>2</font><font face='Lucida Console'>)</font>;
tincx <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>2</font>;
st <font color='#5555FF'>=</font> x<font color='#5555FF'>-</font><font color='#979000'>2</font>;
x <font color='#5555FF'>+</font><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>n<font color='#5555FF'>-</font><font color='#979000'>2</font><font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#0000FF'>do</font>
<b>{</b>
<font color='#5555FF'>*</font>x <font color='#5555FF'>=</font> <font color='#5555FF'>*</font>xx;
x[<font color='#979000'>1</font>] <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>xx[<font color='#979000'>1</font>];
x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> tincx ;
xx <font color='#5555FF'>+</font><font color='#5555FF'>=</font> i;
<b>}</b>
<font color='#0000FF'>while</font> <font face='Lucida Console'>(</font>x <font color='#5555FF'>!</font><font color='#5555FF'>=</font> st<font face='Lucida Console'>)</font>;
x<font color='#5555FF'>=</font>tx;
<font color='#0000FF'>#ifdef</font> F77_INT
F77_incX <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
<font color='#0000FF'>#else</font>
incx <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
<font color='#0000FF'>#endif</font>
<font color='#0000FF'>if</font><font face='Lucida Console'>(</font>incY <font color='#5555FF'>></font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
tincY <font color='#5555FF'>=</font> incY;
<font color='#0000FF'>else</font>
tincY <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>incY;
y<font color='#5555FF'>+</font><font color='#5555FF'>+</font>;
i <font color='#5555FF'>=</font> tincY <font color='#5555FF'><</font><font color='#5555FF'><</font> <font color='#979000'>1</font>;
n <font color='#5555FF'>=</font> i <font color='#5555FF'>*</font> N ;
st <font color='#5555FF'>=</font> y <font color='#5555FF'>+</font> n;
<font color='#0000FF'>do</font> <b>{</b>
<font color='#5555FF'>*</font>y <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font>y<font face='Lucida Console'>)</font>;
y <font color='#5555FF'>+</font><font color='#5555FF'>=</font> i;
<b>}</b> <font color='#0000FF'>while</font><font face='Lucida Console'>(</font>y <font color='#5555FF'>!</font><font color='#5555FF'>=</font> st<font face='Lucida Console'>)</font>;
y <font color='#5555FF'>-</font><font color='#5555FF'>=</font> n;
<b>}</b> <font color='#0000FF'>else</font>
x <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font><font face='Lucida Console'>)</font> X;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Uplo <font color='#5555FF'>=</font><font color='#5555FF'>=</font> CblasUpper<font face='Lucida Console'>)</font> UL <font color='#5555FF'>=</font> '<font color='#FF0000'>L</font>';
<font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Uplo <font color='#5555FF'>=</font><font color='#5555FF'>=</font> CblasLower<font face='Lucida Console'>)</font> UL <font color='#5555FF'>=</font> '<font color='#FF0000'>U</font>';
<font color='#0000FF'>else</font>
<b>{</b>
<font color='#BB00BB'>cblas_xerbla</font><font face='Lucida Console'>(</font><font color='#979000'>2</font>, "<font color='#CC0000'>cblas_chemv</font>","<font color='#CC0000'>Illegal Uplo setting, %d\n</font>", Uplo<font face='Lucida Console'>)</font>;
<font color='#0000FF'>return</font>;
<b>}</b>
<font color='#0000FF'>#ifdef</font> F77_CHAR
F77_UL <font color='#5555FF'>=</font> <font color='#BB00BB'>C2F_CHAR</font><font face='Lucida Console'>(</font><font color='#5555FF'>&</font>UL<font face='Lucida Console'>)</font>;
<font color='#0000FF'>#endif</font>
<font color='#BB00BB'>F77_chemv</font><font face='Lucida Console'>(</font>F77_UL, <font color='#5555FF'>&</font>F77_N, ALPHA, A, <font color='#5555FF'>&</font>F77_lda, x, <font color='#5555FF'>&</font>F77_incX,
BETA, Y, <font color='#5555FF'>&</font>F77_incY<font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#0000FF'>else</font>
<b>{</b>
<font color='#BB00BB'>cblas_xerbla</font><font face='Lucida Console'>(</font><font color='#979000'>1</font>, "<font color='#CC0000'>cblas_chemv</font>","<font color='#CC0000'>Illegal Order setting, %d\n</font>", order<font face='Lucida Console'>)</font>;
<font color='#0000FF'>return</font>;
<b>}</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font> order <font color='#5555FF'>=</font><font color='#5555FF'>=</font> CblasRowMajor <font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font> X <font color='#5555FF'>!</font><font color='#5555FF'>=</font> x <font face='Lucida Console'>)</font>
<font color='#BB00BB'>free</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>N <font color='#5555FF'>></font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>do</font>
<b>{</b>
<font color='#5555FF'>*</font>y <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font>y<font face='Lucida Console'>)</font>;
y <font color='#5555FF'>+</font><font color='#5555FF'>=</font> i;
<b>}</b>
<font color='#0000FF'>while</font> <font face='Lucida Console'>(</font>y <font color='#5555FF'>!</font><font color='#5555FF'>=</font> st<font face='Lucida Console'>)</font>;
<b>}</b>
<b>}</b>
<font color='#0000FF'>return</font>;
<b>}</b>
</pre></body></html> |