|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144 |
- /*****************************************************************************
- Copyright (c) 2023, The OpenBLAS Project
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 3. Neither the name of the OpenBLAS project nor the names of
- its contributors may be used to endorse or promote products
- derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- **********************************************************************************/
-
- #include "utest/openblas_utest.h"
- #include "common.h"
-
- #define N 100
- #define M 100
- #define INCREMENT 2
-
- struct DATA_ZGEMV_T {
- double a_test[N * M * 2];
- double a_verify[N * M * 2];
- double y_test[M * INCREMENT * 2];
- double y_verify[M * INCREMENT * 2];
- double x_test[M * INCREMENT * 2];
- double x_verify[M * INCREMENT * 2];
- };
-
- // DOUBLE_EPS_ZGEMV = MAX_VAL * NUMBER OF OPERATIONS * DBL_EPSILON
- // DOUBLE_EPS_ZGEMV = 5.0 * O(100 * 100) * 2.2e-16 = 1e-11
- #define DOUBLE_EPS_ZGEMV 1e-11
-
- #ifdef BUILD_COMPLEX16
- static struct DATA_ZGEMV_T data_zgemv_t;
-
- /**
- * Find product of matrix-vector multiplication
- *
- * param n specifies number of columns of A
- * param m specifies number of rows of A and size of vector x
- * param lda specifies leading dimension of A
- * param inc_x specifies increment of vector x
- */
- static void matrix_vector_product(blasint n, blasint m, blasint lda, blasint inc_x)
- {
- blasint i;
- blasint one=1;
- double *a_ptr = data_zgemv_t.a_verify;
- double *x_ptr = data_zgemv_t.x_test;
- double *x_res = data_zgemv_t.x_verify;
-
- openblas_complex_double result;
-
- for (i = 0; i < n * inc_x; i += inc_x)
- {
- #ifdef RETURN_BY_STACK
- BLASFUNC(zdotu)(&result, &lda, a_ptr, &one, x_ptr, &inc_x);
- #else
- result = BLASFUNC(zdotu)(&lda, a_ptr, &one, x_ptr, &inc_x);
- #endif
- x_res[0] = CREAL(result);
- x_res[1] = CIMAG(result);
- a_ptr += lda * 2;
- x_res += 2 * inc_x;
- }
- }
-
- /**
- * Test zgemv by comparing it against zomatcopy, zaxpby and
- * reference func matrix_vector_product
- *
- * zomatcopy perform operation: op(A)
- * matrix_vector_product perform operation: A*x
- * zaxpby perform operation: alpha*x + beta*y
- *
- * param api specifies tested api (C or Fortran)
- * param order specifies row or column major order
- * param trans specifies op(A), the transposition operation
- * applied to the matrix A
- * param m specifies number of rows of A
- * param n specifies number of columns of A
- * param alpha specifies scalar alpha
- * param lda specifies leading dimension of the matrix A
- * param inc_x specifies increment for vector x
- * param beta specifies scalar beta
- * param inc_y specifies increment for vector y
- * return norm of difference between zgemv and result of reference funcs
- */
- static double check_zgemv(char api, char order, char trans, blasint m, blasint n, double *alpha,
- blasint lda, blasint inc_x, double *beta, blasint inc_y)
- {
- blasint i;
-
- enum CBLAS_ORDER corder;
- enum CBLAS_TRANSPOSE ctrans;
-
- // Transpose parameters for zomatcopy
- // zgemv_t perform operation on transposed matrix, no need to transpose a_verify
- char trans_copy;
- char ctrans_copy;
-
- // Param alpha for zomatcopy, scale on alpha perform zaxpby
- double alpha_one[] = {1.0, 0.0};
-
- memset(data_zgemv_t.x_verify, 0.0, m * inc_x * 2 * sizeof(double));
-
- // Fill matrix A, vectors x, y
- drand_generate(data_zgemv_t.a_test, lda * n * 2);
- drand_generate(data_zgemv_t.x_test, m * inc_x * 2);
- drand_generate(data_zgemv_t.y_test, m * inc_y * 2);
-
- // Copy vector y for reference funcs
- for (i = 0; i < m * inc_y * 2; i++)
- {
- data_zgemv_t.y_verify[i] = data_zgemv_t.y_test[i];
- }
-
- if (api == 'F') {
- if (trans == 'T') trans_copy = 'N';
- if (trans == 'C') trans_copy = 'R';
- if (trans == 'U') trans_copy = 'R';
- if (trans == 'D') trans_copy = 'N';
-
- // Perform operation: op(A)
- BLASFUNC(zomatcopy)(&order, &trans_copy, &m, &n, alpha_one,
- data_zgemv_t.a_test, &lda, data_zgemv_t.a_verify, &lda);
-
- // Find A*x
- matrix_vector_product(n, m, lda, inc_x);
-
- // Find conj(x)
- if (trans == 'U' || trans == 'D')
- {
- zconjugate_vector(m, inc_x, data_zgemv_t.x_verify);
- }
-
- // Find alpha*x+beta*y
- BLASFUNC(zaxpby)(&n, alpha, data_zgemv_t.x_verify, &inc_x, beta,
- data_zgemv_t.y_verify, &inc_y);
-
- BLASFUNC(zgemv)(&trans, &m, &n, alpha, data_zgemv_t.a_test, &lda,
- data_zgemv_t.x_test, &inc_x, beta, data_zgemv_t.y_test, &inc_y);
- }
- #ifndef NO_CBLAS
- else {
- if (order == 'C') corder = CblasColMajor;
- if (order == 'R') corder = CblasRowMajor;
- if (trans == 'T') {ctrans = CblasTrans; ctrans_copy = (corder == CblasRowMajor) ? CblasTrans : CblasNoTrans;}
- if (trans == 'N') {ctrans = CblasNoTrans; ctrans_copy = (corder == CblasRowMajor) ? CblasNoTrans : CblasTrans;}
- if (trans == 'C') {ctrans = CblasConjTrans; ctrans_copy = (corder == CblasRowMajor) ? CblasConjTrans : CblasConjNoTrans;}
- if (trans == 'R') {ctrans = CblasConjNoTrans; ctrans_copy = (corder == CblasRowMajor) ? CblasConjNoTrans : CblasConjTrans;}
-
- // Perform operation: op(A)
- cblas_zomatcopy(corder, ctrans_copy, m, n, alpha_one, data_zgemv_t.a_test, lda, data_zgemv_t.a_verify, lda);
-
- // Find A*x
- matrix_vector_product(n, m, lda, inc_x);
-
- // Find alpha*x+beta*y
- cblas_zaxpby(n, alpha, data_zgemv_t.x_verify, inc_x, beta, data_zgemv_t.y_verify, inc_y);
-
- cblas_zgemv(corder, ctrans, m, n, alpha, data_zgemv_t.a_test,
- lda, data_zgemv_t.x_test, inc_x, beta, data_zgemv_t.y_test, inc_y);
- }
- #endif
-
- // Find the differences between output vector caculated by zgemv and reference funcs
- for (i = 0; i < m * inc_y * 2; i++)
- data_zgemv_t.y_test[i] -= data_zgemv_t.y_verify[i];
-
- // Find the norm of differences
- return BLASFUNC(dznrm2)(&m, data_zgemv_t.y_test, &inc_y);
- }
-
- /**
- * Check if error function was called with expected function name
- * and param info
- *
- * param order specifies row or column major order
- * param trans specifies op(A), the transposition operation
- * applied to the matrix A
- * param m specifies number of rows of A
- * param n specifies number of columns of A
- * param lda specifies leading dimension of the matrix A
- * param inc_x specifies increment for vector x
- * param inc_y specifies increment for vector y
- * param expected_info - expected invalid parameter number
- * return TRUE if everything is ok, otherwise FALSE
- */
- static int check_badargs(char order, char trans, blasint m, blasint n,
- blasint lda, blasint inc_x, blasint inc_y, int expected_info)
- {
- double alpha[] = {1.0, 1.0};
- double a[] = {1.0, 1.0};
- double x[] = {1.0, 1.0};
- double beta[] = {1.0, 1.0};
- double y[] = {1.0, 1.0};
-
- set_xerbla("ZGEMV ", expected_info);
-
- BLASFUNC(zgemv)(&trans, &m, &n, alpha, a, &lda, x,
- &inc_x, beta, y, &inc_y);
-
- return check_error();
- }
- #ifndef NO_CBLAS
- /**
- * C API specific function
- * Check if error function was called with expected function name
- * and param info
- *
- * param order specifies row or column major order
- * param trans specifies op(A), the transposition operation
- * applied to the matrix A
- * param m specifies number of rows of A
- * param n specifies number of columns of A
- * param lda specifies leading dimension of the matrix A
- * param inc_x specifies increment for vector x
- * param inc_y specifies increment for vector y
- * param expected_info - expected invalid parameter number
- * return TRUE if everything is ok, otherwise FALSE
- */
- static int c_api_check_badargs(CBLAS_ORDER corder, CBLAS_TRANSPOSE ctrans, blasint m, blasint n,
- blasint lda, blasint inc_x, blasint inc_y, int expected_info)
- {
- double alpha[] = {1.0, 1.0};
- double a[] = {1.0, 1.0};
- double x[] = {1.0, 1.0};
- double beta[] = {1.0, 1.0};
- double y[] = {1.0, 1.0};
-
- set_xerbla("ZGEMV ", expected_info);
-
- cblas_zgemv(corder, ctrans, m, n, alpha, a, lda, x, inc_x, beta, y, inc_y);
-
- return check_error();
- }
-
- /**
- * Fortran API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition
- * Square matrix
- * inc x = 2, inc y = 1
- * alpha_r = 1.0, alpha_i = 1.0
- * beta_r = 2.0, beta_i = 2.0
- */
- CTEST(zgemv, colmajor_trans_col_100_row_100_inc_x_1_y_1)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'T';
-
- double alpha[] = {2.0, 1.0};
- double beta[] = {1.0, 2.0};
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- double norm = check_zgemv('F', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * Fortran API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition
- * Square matrix
- * inc x = 2, inc y = 1
- * alpha_r = 1.0, alpha_i = 1.0
- * beta_r = 2.0, beta_i = 2.0
- */
- CTEST(zgemv, colmajor_trans_col_100_row_100_inc_x_2_y_1)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'T';
-
- double alpha[] = {1.0, 1.0};
- double beta[] = {2.0, 2.0};
-
- blasint inc_x = 2;
- blasint inc_y = 1;
-
- double norm = check_zgemv('F', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * Fortran API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition and conjugate A
- * Square matrix
- * inc x = 1, inc y = 1
- * alpha_r = 2.0, alpha_i = 1.0
- * beta_r = 2.0, beta_i = 1.0
- */
- CTEST(zgemv, colmajor_conjtrans_col_100_row_100_inc_x_1_y_1)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'C';
-
- double alpha[] = {2.0, 1.0};
- double beta[] = {2.0, 1.0};
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- double norm = check_zgemv('F', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * Fortran API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition and conjugate A
- * Square matrix
- * inc x = 1, inc y = 2
- * alpha_r = 2.0, alpha_i = 1.0
- * beta_r = 2.0, beta_i = 1.0
- */
- CTEST(zgemv, colmajor_conjtrans_col_100_row_100_inc_x_1_y_2)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'C';
-
- double alpha[] = {1.0, 1.0};
- double beta[] = {1.0, 1.0};
-
- blasint inc_x = 1;
- blasint inc_y = 2;
-
- double norm = check_zgemv('F', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * Fortran API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition and x conjugate
- * Square matrix
- * inc x = 1, inc y = 1
- * alpha_r = 2.0, alpha_i = 1.0
- * beta_r = 2.0, beta_i = 1.0
- */
- CTEST(zgemv, colmajor_trans_x_conj_col_100_row_100_inc_x_1_y_1)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'U';
-
- double alpha[] = {1.0, 1.0};
- double beta[] = {1.0, 1.0};
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- double norm = check_zgemv('F', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * Fortran API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition and x conjugate
- * Square matrix
- * inc x = 2, inc y = 2
- * alpha_r = 1.0, alpha_i = 2.0
- * beta_r = 1.0, beta_i = 1.0
- */
- CTEST(zgemv, colmajor_trans_x_conj_col_100_row_100_inc_x_2_y_2)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'U';
-
- double alpha[] = {1.0, 2.0};
- double beta[] = {1.0, 1.0};
-
- blasint inc_x = 2;
- blasint inc_y = 2;
-
- double norm = check_zgemv('F', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * Fortran API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition, conjugate A, conjugate x
- * Square matrix
- * inc x = 2, inc y = 2
- * alpha_r = 2.0, alpha_i = 1.0
- * beta_r = 1.0, beta_i = 2.0
- */
- CTEST(zgemv, colmajor_conjtrans_x_conj_col_100_row_100_inc_x_1_y_2)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'D';
-
- double alpha[] = {2.0, 1.0};
- double beta[] = {1.0, 2.0};
-
- blasint inc_x = 1;
- blasint inc_y = 2;
-
- double norm = check_zgemv('F', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * C API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition, conjugate A, conjugate x
- * Square matrix
- * inc x = 2, inc y = 1
- * alpha_r = 2.0, alpha_i = 1.0
- * beta_r = 1.0, beta_i = 2.0
- */
- CTEST(zgemv, c_api_colmajor_trans_col_100_row_100_inc_x_1_y_1)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'T';
-
- double alpha[] = {2.0, 1.0};
- double beta[] = {1.0, 2.0};
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- double norm = check_zgemv('C', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * C API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition and conjugate A
- * Square matrix
- * inc x = 2, inc y = 1
- * alpha_r = 1.0, alpha_i = 1.0
- * beta_r = 1.0, beta_i = 2.0
- */
- CTEST(zgemv, c_api_colmajor_conjtrans_col_100_row_100_inc_x_1_y_1)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'C';
-
- double alpha[] = {1.0, 1.0};
- double beta[] = {1.0, 2.0};
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- double norm = check_zgemv('C', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * C API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Transposition and conjugate A
- * Square matrix
- * inc x = 1, inc y = 2
- * alpha_r = 1.0, alpha_i = 1.0
- * beta_r = 1.0, beta_i = 2.0
- */
- CTEST(zgemv, c_api_colmajor_conjtrans_col_100_row_100_inc_x_1_y_2)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'C';
- char trans = 'C';
-
- double alpha[] = {1.0, 1.0};
- double beta[] = {1.0, 2.0};
-
- blasint inc_x = 1;
- blasint inc_y = 2;
-
- double norm = check_zgemv('C', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * C API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Row Major
- * Square matrix
- * inc x = 1, inc y = 1
- * alpha_r = 2.0, alpha_i = 1.0
- * beta_r = 1.0, beta_i = 1.0
- */
- CTEST(zgemv, c_api_rowmajor_notrans_col_100_row_100_inc_x_1_y_1)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'R';
- char trans = 'N';
-
- double alpha[] = {2.0, 1.0};
- double beta[] = {1.0, 1.0};
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- double norm = check_zgemv('C', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * C API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Row Major
- * No trans
- * Square matrix
- * inc x = 2, inc y = 2
- * alpha_r = 1.0, alpha_i = 1.0
- * beta_r = 3.0, beta_i = 2.0
- */
- CTEST(zgemv, c_api_rowmajor_notrans_col_100_row_100_inc_x_2_y_2)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'R';
- char trans = 'N';
-
- double alpha[] = {1.0, 1.0};
- double beta[] = {3.0, 1.0};
-
- blasint inc_x = 2;
- blasint inc_y = 2;
-
- double norm = check_zgemv('C', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * C API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Column Major
- * Conjugate
- * Square matrix
- * inc x = 1, inc y = 1
- * alpha_r = 1.0, alpha_i = 3.0
- * beta_r = 1.0, beta_i = 2.5
- */
- CTEST(zgemv, c_api_rowmajor_conj_col_100_row_100_inc_x_1_y_1)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'R';
- char trans = 'R';
-
- double alpha[] = {1.0, 3.0};
- double beta[] = {1.0, 2.5};
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- double norm = check_zgemv('C', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * C API specific test
- * Test zgemv by comparing it against reference
- * with the following options:
- *
- * Row Major
- * Conjugate
- * Square matrix
- * inc x = 2, inc y = 1
- * alpha_r = 1.0, alpha_i = 1.0
- * beta_r = 1.0, beta_i = 1.5
- */
- CTEST(zgemv, c_api_rowmajor_conj_col_100_row_100_inc_x_2_y_1)
- {
- blasint m = 100, n = 100;
- blasint lda = 100;
- char order = 'R';
- char trans = 'R';
-
- double alpha[] = {1.0, 1.0};
- double beta[] = {1.0, 1.5};
-
- blasint inc_x = 2;
- blasint inc_y = 1;
-
- double norm = check_zgemv('C', order, trans, m, n, alpha, lda,
- inc_x, beta, inc_y);
-
- ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS_ZGEMV);
- }
-
- /**
- * Fortran API specific test
- * Test error function for an invalid param inc_y.
- * Must be positive
- *
- * Column major
- */
- CTEST(zgemv, xerbla_invalid_inc_y)
- {
- char order = 'C';
- char trans = 'T';
-
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 0;
-
- int expected_info = 11;
-
- int passed = check_badargs(order, trans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param inc_y.
- * Must be positive
- *
- * Column major
- */
- CTEST(zgemv, c_api_xerbla_invalid_inc_y_col_major)
- {
- enum CBLAS_ORDER corder = CblasColMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasTrans;
-
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 0;
-
- int expected_info = 11;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param inc_y.
- * Must be positive
- *
- * Row major
- */
- CTEST(zgemv, c_api_xerbla_invalid_inc_y_row_major)
- {
- enum CBLAS_ORDER corder = CblasRowMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasNoTrans;
-
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 0;
-
- int expected_info = 11;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * Fortran API specific test
- * Test error function for an invalid param inc_x.
- * Must be positive
- *
- * Column major
- */
- CTEST(zgemv, xerbla_invalid_inc_x)
- {
- char order = 'C';
- char trans = 'T';
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 0;
- blasint inc_y = 1;
-
- int expected_info = 8;
-
- int passed = check_badargs(order, trans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param inc_x.
- * Must be positive
- *
- * Column major
- */
- CTEST(zgemv, c_api_xerbla_invalid_inc_x_col_major)
- {
- enum CBLAS_ORDER corder = CblasColMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasTrans;
-
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 0;
- blasint inc_y = 1;
-
- int expected_info = 8;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param inc_x.
- * Must be positive
- *
- * Row major
- */
- CTEST(zgemv, c_api_xerbla_invalid_inc_x_row_major)
- {
- enum CBLAS_ORDER corder = CblasColMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasTrans;
-
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 0;
- blasint inc_y = 1;
-
- int expected_info = 8;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * Fortran API specific test
- * Test error function for an invalid param n.
- * Must be positive.
- *
- * Column major
- */
- CTEST(zgemv, xerbla_invalid_n)
- {
- char order = 'C';
- char trans = 'T';
-
- blasint m = 1, n = INVALID;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 3;
-
- int passed = check_badargs(order, trans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param n.
- * Must be positive.
- *
- * Column major
- */
- CTEST(zgemv, c_api_xerbla_invalid_n_col_major)
- {
- enum CBLAS_ORDER corder = CblasColMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasTrans;
-
- blasint m = 1, n = INVALID;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 3;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param n.
- * Must be positive.
- *
- * Row major
- */
- CTEST(zgemv, c_api_xerbla_invalid_n_row_major)
- {
- enum CBLAS_ORDER corder = CblasRowMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasNoTrans;
-
- blasint m = INVALID, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 3;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * Fortran API specific test
- * Test error function for an invalid param m.
- * Must be positive.
- *
- * Column major
- */
- CTEST(zgemv, xerbla_invalid_m)
- {
- char order = 'C';
- char trans = 'T';
-
- blasint m = INVALID, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 2;
-
- int passed = check_badargs(order, trans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param m.
- * Must be positive.
- *
- * Column major
- */
- CTEST(zgemv, c_api_xerbla_invalid_m_col_major)
- {
- enum CBLAS_ORDER corder = CblasColMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasTrans;
-
- blasint m = INVALID, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 2;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param m.
- * Must be positive.
- *
- * Row major
- */
- CTEST(zgemv, c_api_xerbla_invalid_m_row_major)
- {
- enum CBLAS_ORDER corder = CblasRowMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasNoTrans;
-
- blasint m = 1, n = INVALID;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 2;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * Fortran API specific test
- * Test error function for an invalid param lda.
- * lda must be at least n.
- *
- * Column major
- */
- CTEST(zgemv, xerbla_invalid_lda)
- {
- char order = 'C';
- char trans = 'T';
-
- blasint m = 1, n = 1;
- blasint lda = INVALID;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 6;
-
- int passed = check_badargs(order, trans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param lda.
- * If matrices are stored using col major layout,
- * lda must be at least m.
- *
- * Column major
- */
- CTEST(zgemv, c_api_xerbla_invalid_lda_col_major)
- {
- enum CBLAS_ORDER corder = CblasColMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasTrans;
-
- blasint m = 1, n = 1;
- blasint lda = INVALID;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 6;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param lda.
- * If matrices are stored using col major layout,
- * lda must be at least n.
- *
- * Column major
- */
- CTEST(zgemv, c_api_xerbla_invalid_lda_row_major)
- {
- enum CBLAS_ORDER corder = CblasRowMajor;
- enum CBLAS_TRANSPOSE ctrans = CblasNoTrans;
-
- blasint m = 1, n = 1;
- blasint lda = INVALID;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 6;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * Fortran API specific test
- * Test error function for an invalid param trans.
- *
- * Column major
- */
- CTEST(zgemv, xerbla_invalid_trans)
- {
- char order = 'C';
- char trans = 'Z';
-
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 1;
-
- int passed = check_badargs(order, trans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param trans.
- *
- * Column major
- */
- CTEST(zgemv, c_api_xerbla_invalid_trans_col_major)
- {
- enum CBLAS_ORDER corder = CblasColMajor;
- enum CBLAS_TRANSPOSE ctrans = INVALID;
-
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 1;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param trans.
- *
- * Row major
- */
- CTEST(zgemv, c_api_xerbla_invalid_trans_row_major)
- {
- enum CBLAS_ORDER corder = CblasRowMajor;
- enum CBLAS_TRANSPOSE ctrans = INVALID;
-
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 1;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
-
- /**
- * C API specific test
- * Test error function for an invalid param order.
- */
- CTEST(zgemv, c_api_xerbla_invalid_order_col_major)
- {
- enum CBLAS_ORDER corder = INVALID;
- enum CBLAS_TRANSPOSE ctrans = CblasTrans;
-
- blasint m = 1, n = 1;
- blasint lda = 1;
-
- blasint inc_x = 1;
- blasint inc_y = 1;
-
- int expected_info = 0;
-
- int passed = c_api_check_badargs(corder, ctrans, m, n, lda, inc_x, inc_y, expected_info);
- ASSERT_EQUAL(TRUE, passed);
- }
- #endif
- #endif
|