Mercurial > hg > octave-nkf
changeset 11516:53edbf95fbb6
avoid GCC warnings
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 13 Jan 2011 15:40:14 -0500 |
parents | 6dbf9bcce90e |
children | da8e32c99969 |
files | liboctave/CMatrix.cc liboctave/ChangeLog liboctave/dMatrix.cc liboctave/fCMatrix.cc liboctave/fMatrix.cc |
diffstat | 5 files changed, 59 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -3692,11 +3692,10 @@ %!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14) */ -static const char * +static inline char get_blas_trans_arg (bool trans, bool conj) { - static char blas_notrans = 'N', blas_trans = 'T', blas_conj_trans = 'C'; - return trans ? (conj ? &blas_conj_trans : &blas_trans) : &blas_notrans; + return trans ? (conj ? 'C' : 'T') : 'N'; } // the general GEMM operation @@ -3729,11 +3728,11 @@ retval = ComplexMatrix (a_nr, b_nc); Complex *c = retval.fortran_vec (); - const char *ctra = get_blas_trans_arg (tra, cja); + const char ctra = get_blas_trans_arg (tra, cja); if (cja || cjb) { F77_XFCN (zherk, ZHERK, (F77_CONST_CHAR_ARG2 ("U", 1), - F77_CONST_CHAR_ARG2 (ctra, 1), + F77_CONST_CHAR_ARG2 (&ctra, 1), a_nr, a_nc, 1.0, a.data (), lda, 0.0, c, a_nr F77_CHAR_ARG_LEN (1) @@ -3745,7 +3744,7 @@ else { F77_XFCN (zsyrk, ZSYRK, (F77_CONST_CHAR_ARG2 ("U", 1), - F77_CONST_CHAR_ARG2 (ctra, 1), + F77_CONST_CHAR_ARG2 (&ctra, 1), a_nr, a_nc, 1.0, a.data (), lda, 0.0, c, a_nr F77_CHAR_ARG_LEN (1) @@ -3779,26 +3778,26 @@ } else if (b_nc == 1 && ! cjb) { - const char *ctra = get_blas_trans_arg (tra, cja); - F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (ctra, 1), + const char ctra = get_blas_trans_arg (tra, cja); + F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1), lda, tda, 1.0, a.data (), lda, b.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } else if (a_nr == 1 && ! cja && ! cjb) { - const char *crevtrb = get_blas_trans_arg (! trb, cjb); - F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (crevtrb, 1), + const char crevtrb = get_blas_trans_arg (! trb, cjb); + F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1), ldb, tdb, 1.0, b.data (), ldb, a.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } else { - const char *ctra = get_blas_trans_arg (tra, cja); - const char *ctrb = get_blas_trans_arg (trb, cjb); - F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 (ctra, 1), - F77_CONST_CHAR_ARG2 (ctrb, 1), + const char ctra = get_blas_trans_arg (tra, cja); + const char ctrb = get_blas_trans_arg (trb, cjb); + F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1), + F77_CONST_CHAR_ARG2 (&ctrb, 1), a_nr, b_nc, a_nc, 1.0, a.data (), lda, b.data (), ldb, 0.0, c, a_nr F77_CHAR_ARG_LEN (1)
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,12 @@ +2011-01-13 John W. Eaton <jwe@octave.org> + + * CMatrix.cc (get_blas_trans_arg): Return char, not char *. + Change all uses. + * dMatrix.cc (get_blas_trans_arg): Likewise. + * fCMatrix.cc (get_blas_trans_arg): Likewise. + * fMatrix.cc (get_blas_trans_arg): Likewise. + Suggested by Pascal Dupuis <Pascal.Dupuis@worldonline.be>. + 2011-01-13 John W. Eaton <jwe@octave.org> * filemode.c: Use prototypes for function definitions. Reorder
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -3096,11 +3096,10 @@ %!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14) */ -static const char * +static inline char get_blas_trans_arg (bool trans) { - static char blas_notrans = 'N', blas_trans = 'T'; - return (trans) ? &blas_trans : &blas_notrans; + return trans ? 'T' : 'N'; } // the general GEMM operation @@ -3132,9 +3131,9 @@ retval = Matrix (a_nr, b_nc); double *c = retval.fortran_vec (); - const char *ctra = get_blas_trans_arg (tra); + const char ctra = get_blas_trans_arg (tra); F77_XFCN (dsyrk, DSYRK, (F77_CONST_CHAR_ARG2 ("U", 1), - F77_CONST_CHAR_ARG2 (ctra, 1), + F77_CONST_CHAR_ARG2 (&ctra, 1), a_nr, a_nc, 1.0, a.data (), lda, 0.0, c, a_nr F77_CHAR_ARG_LEN (1) @@ -3158,8 +3157,8 @@ F77_FUNC (xddot, XDDOT) (a_nc, a.data (), 1, b.data (), 1, *c); else { - const char *ctra = get_blas_trans_arg (tra); - F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (ctra, 1), + const char ctra = get_blas_trans_arg (tra); + F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1), lda, tda, 1.0, a.data (), lda, b.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); @@ -3167,18 +3166,18 @@ } else if (a_nr == 1) { - const char *crevtrb = get_blas_trans_arg (! trb); - F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (crevtrb, 1), + const char crevtrb = get_blas_trans_arg (! trb); + F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1), ldb, tdb, 1.0, b.data (), ldb, a.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } else { - const char *ctra = get_blas_trans_arg (tra); - const char *ctrb = get_blas_trans_arg (trb); - F77_XFCN (dgemm, DGEMM, (F77_CONST_CHAR_ARG2 (ctra, 1), - F77_CONST_CHAR_ARG2 (ctrb, 1), + const char ctra = get_blas_trans_arg (tra); + const char ctrb = get_blas_trans_arg (trb); + F77_XFCN (dgemm, DGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1), + F77_CONST_CHAR_ARG2 (&ctrb, 1), a_nr, b_nc, a_nc, 1.0, a.data (), lda, b.data (), ldb, 0.0, c, a_nr F77_CHAR_ARG_LEN (1)
--- a/liboctave/fCMatrix.cc +++ b/liboctave/fCMatrix.cc @@ -3685,11 +3685,10 @@ %!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-6) */ -static const char * +static char get_blas_trans_arg (bool trans, bool conj) { - static char blas_notrans = 'N', blas_trans = 'T', blas_conj_trans = 'C'; - return trans ? (conj ? &blas_conj_trans : &blas_trans) : &blas_notrans; + return trans ? (conj ? 'C' : 'T') : 'N'; } // the general GEMM operation @@ -3722,11 +3721,11 @@ retval = FloatComplexMatrix (a_nr, b_nc); FloatComplex *c = retval.fortran_vec (); - const char *ctra = get_blas_trans_arg (tra, cja); + const char ctra = get_blas_trans_arg (tra, cja); if (cja || cjb) { F77_XFCN (cherk, CHERK, (F77_CONST_CHAR_ARG2 ("U", 1), - F77_CONST_CHAR_ARG2 (ctra, 1), + F77_CONST_CHAR_ARG2 (&ctra, 1), a_nr, a_nc, 1.0, a.data (), lda, 0.0, c, a_nr F77_CHAR_ARG_LEN (1) @@ -3738,7 +3737,7 @@ else { F77_XFCN (csyrk, CSYRK, (F77_CONST_CHAR_ARG2 ("U", 1), - F77_CONST_CHAR_ARG2 (ctra, 1), + F77_CONST_CHAR_ARG2 (&ctra, 1), a_nr, a_nc, 1.0, a.data (), lda, 0.0, c, a_nr F77_CHAR_ARG_LEN (1) @@ -3772,26 +3771,26 @@ } else if (b_nc == 1 && ! cjb) { - const char *ctra = get_blas_trans_arg (tra, cja); - F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (ctra, 1), + const char ctra = get_blas_trans_arg (tra, cja); + F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1), lda, tda, 1.0, a.data (), lda, b.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } else if (a_nr == 1 && ! cja && ! cjb) { - const char *crevtrb = get_blas_trans_arg (! trb, cjb); - F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (crevtrb, 1), + const char crevtrb = get_blas_trans_arg (! trb, cjb); + F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1), ldb, tdb, 1.0, b.data (), ldb, a.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } else { - const char *ctra = get_blas_trans_arg (tra, cja); - const char *ctrb = get_blas_trans_arg (trb, cjb); - F77_XFCN (cgemm, CGEMM, (F77_CONST_CHAR_ARG2 (ctra, 1), - F77_CONST_CHAR_ARG2 (ctrb, 1), + const char ctra = get_blas_trans_arg (tra, cja); + const char ctrb = get_blas_trans_arg (trb, cjb); + F77_XFCN (cgemm, CGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1), + F77_CONST_CHAR_ARG2 (&ctrb, 1), a_nr, b_nc, a_nc, 1.0, a.data (), lda, b.data (), ldb, 0.0, c, a_nr F77_CHAR_ARG_LEN (1)
--- a/liboctave/fMatrix.cc +++ b/liboctave/fMatrix.cc @@ -3095,11 +3095,10 @@ %!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-6) */ -static const char * +static char get_blas_trans_arg (bool trans) { - static char blas_notrans = 'N', blas_trans = 'T'; - return (trans) ? &blas_trans : &blas_notrans; + return trans ? 'T' : 'N'; } // the general GEMM operation @@ -3131,9 +3130,9 @@ retval = FloatMatrix (a_nr, b_nc); float *c = retval.fortran_vec (); - const char *ctra = get_blas_trans_arg (tra); + const char ctra = get_blas_trans_arg (tra); F77_XFCN (ssyrk, SSYRK, (F77_CONST_CHAR_ARG2 ("U", 1), - F77_CONST_CHAR_ARG2 (ctra, 1), + F77_CONST_CHAR_ARG2 (&ctra, 1), a_nr, a_nc, 1.0, a.data (), lda, 0.0, c, a_nr F77_CHAR_ARG_LEN (1) @@ -3157,8 +3156,8 @@ F77_FUNC (xsdot, XSDOT) (a_nc, a.data (), 1, b.data (), 1, *c); else { - const char *ctra = get_blas_trans_arg (tra); - F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 (ctra, 1), + const char ctra = get_blas_trans_arg (tra); + F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1), lda, tda, 1.0, a.data (), lda, b.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); @@ -3166,18 +3165,18 @@ } else if (a_nr == 1) { - const char *crevtrb = get_blas_trans_arg (! trb); - F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 (crevtrb, 1), + const char crevtrb = get_blas_trans_arg (! trb); + F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1), ldb, tdb, 1.0, b.data (), ldb, a.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } else { - const char *ctra = get_blas_trans_arg (tra); - const char *ctrb = get_blas_trans_arg (trb); - F77_XFCN (sgemm, SGEMM, (F77_CONST_CHAR_ARG2 (ctra, 1), - F77_CONST_CHAR_ARG2 (ctrb, 1), + const char ctra = get_blas_trans_arg (tra); + const char ctrb = get_blas_trans_arg (trb); + F77_XFCN (sgemm, SGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1), + F77_CONST_CHAR_ARG2 (&ctrb, 1), a_nr, b_nc, a_nc, 1.0, a.data (), lda, b.data (), ldb, 0.0, c, a_nr F77_CHAR_ARG_LEN (1)