Example #1
0
int CORE_sormqr(int side, int trans,
                int M, int N, int K, int IB,
                float *A, int LDA,
                float *T, int LDT,
                float *C, int LDC,
                float *WORK, int LDWORK)
{
    int i, kb;
    int i1, i3;
    int nq, nw;
    int ic = 0;
    int jc = 0;
    int ni = N;
    int mi = M;

    /* Check input arguments */
    if ((side != PlasmaLeft) && (side != PlasmaRight)) {
        coreblas_error(1, "Illegal value of side");
        return -1;
    }
    /*
     * NQ is the order of Q and NW is the minimum dimension of WORK
     */
    if (side == PlasmaLeft) {
        nq = M;
        nw = N;
    }
    else {
        nq = N;
        nw = M;
    }

    if ((trans != PlasmaNoTrans) && (trans != PlasmaTrans)) {
        coreblas_error(2, "Illegal value of trans");
        return -2;
    }
    if (M < 0) {
        coreblas_error(3, "Illegal value of M");
        return -3;
    }
    if (N < 0) {
        coreblas_error(4, "Illegal value of N");
        return -4;
    }
    if ((K < 0) || (K > nq)) {
        coreblas_error(5, "Illegal value of K");
        return -5;
    }
    if ((IB < 0) || ( (IB == 0) && ((M > 0) && (N > 0)) )) {
        coreblas_error(6, "Illegal value of IB");
        return -6;
    }
    if ((LDA < max(1,nq)) && (nq > 0)) {
        coreblas_error(8, "Illegal value of LDA");
        return -8;
    }
    if ((LDC < max(1,M)) && (M > 0)) {
        coreblas_error(12, "Illegal value of LDC");
        return -12;
    }
    if ((LDWORK < max(1,nw)) && (nw > 0)) {
        coreblas_error(14, "Illegal value of LDWORK");
        return -14;
    }

    /* Quick return */
    if ((M == 0) || (N == 0) || (K == 0))
        return PLASMA_SUCCESS;

    if (((side == PlasmaLeft) && (trans != PlasmaNoTrans))
        || ((side == PlasmaRight) && (trans == PlasmaNoTrans))) {
        i1 = 0;
        i3 = IB;
    }
    else {
        i1 = ( ( K-1 ) / IB )*IB;
        i3 = -IB;
    }

    for(i = i1; (i >- 1) && (i < K); i+=i3 ) {
        kb = min(IB, K-i);

        if (side == PlasmaLeft) {
            /*
             * H or H' is applied to C(i:m,1:n)
             */
            mi = M - i;
            ic = i;
        }
        else {
            /*
             * H or H' is applied to C(1:m,i:n)
             */
            ni = N - i;
            jc = i;
        }
        /*
         * Apply H or H'
         */
        LAPACKE_slarfb_work(LAPACK_COL_MAJOR,
            lapack_const(side),
            lapack_const(trans),
            lapack_const(PlasmaForward),
            lapack_const(PlasmaColumnwise),
            mi, ni, kb,
            &A[LDA*i+i], LDA,
            &T[LDT*i], LDT,
            &C[LDC*jc+ic], LDC,
            WORK, LDWORK);
    }
    return PLASMA_SUCCESS;
}
Example #2
0
lapack_int LAPACKE_slarfb( int matrix_order, char side, char trans, char direct,
                           char storev, lapack_int m, lapack_int n,
                           lapack_int k, const float* v, lapack_int ldv,
                           const float* t, lapack_int ldt, float* c,
                           lapack_int ldc )
{
    lapack_int info = 0;
    lapack_int ldwork = ( side=='l')?n:(( side=='r')?m:1);
    float* work = NULL;
    if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
        LAPACKE_xerbla( "LAPACKE_slarfb", -1 );
        return -1;
    }
#ifndef LAPACK_DISABLE_NAN_CHECK
    /* Optionally check input matrices for NaNs */
    lapack_int ncols_v = LAPACKE_lsame( storev, 'c' ) ? k :
                         ( ( LAPACKE_lsame( storev, 'r' ) &&
                         LAPACKE_lsame( side, 'l' ) ) ? m :
                         ( ( LAPACKE_lsame( storev, 'r' ) &&
                         LAPACKE_lsame( side, 'r' ) ) ? n : 1) );
    lapack_int nrows_v = ( LAPACKE_lsame( storev, 'c' ) &&
                         LAPACKE_lsame( side, 'l' ) ) ? m :
                         ( ( LAPACKE_lsame( storev, 'c' ) &&
                         LAPACKE_lsame( side, 'r' ) ) ? n :
                         ( LAPACKE_lsame( storev, 'r' ) ? k : 1) );
    if( LAPACKE_sge_nancheck( matrix_order, m, n, c, ldc ) ) {
        return -13;
    }
    if( LAPACKE_sge_nancheck( matrix_order, k, k, t, ldt ) ) {
        return -11;
    }
    if( LAPACKE_lsame( storev, 'c' ) && LAPACKE_lsame( direct, 'f' ) ) {
        if( LAPACKE_str_nancheck( matrix_order, 'l', 'u', k, v, ldv ) )
            return -9;
        if( LAPACKE_sge_nancheck( matrix_order, nrows_v-k, ncols_v, &v[k*ldv],
            ldv ) )
            return -9;
    } else if( LAPACKE_lsame( storev, 'c' ) && LAPACKE_lsame( direct, 'b' ) ) {
        if( k > nrows_v ) {
            LAPACKE_xerbla( "LAPACKE_slarfb", -8 );
            return -8;
        }
        if( LAPACKE_str_nancheck( matrix_order, 'u', 'u', k,
            &v[(nrows_v-k)*ldv], ldv ) )
            return -9;
        if( LAPACKE_sge_nancheck( matrix_order, nrows_v-k, ncols_v, v, ldv ) )
            return -9;
    } else if( LAPACKE_lsame( storev, 'r' ) && LAPACKE_lsame( direct, 'f' ) ) {
        if( LAPACKE_str_nancheck( matrix_order, 'u', 'u', k, v, ldv ) )
            return -9;
        if( LAPACKE_sge_nancheck( matrix_order, nrows_v, ncols_v-k, &v[k],
            ldv ) )
            return -9;
    } else if( LAPACKE_lsame( storev, 'r' ) && LAPACKE_lsame( direct, 'f' ) ) {
        if( k > ncols_v ) {
            LAPACKE_xerbla( "LAPACKE_slarfb", -8 );
            return -8;
        }
        if( LAPACKE_str_nancheck( matrix_order, 'l', 'u', k, &v[ncols_v-k],
            ldv ) )
            return -9;
        if( LAPACKE_sge_nancheck( matrix_order, nrows_v, ncols_v-k, v, ldv ) )
            return -9;
    }
#endif
    /* Allocate memory for working array(s) */
    work = (float*)LAPACKE_malloc( sizeof(float) * ldwork * MAX(1,k) );
    if( work == NULL ) {
        info = LAPACK_WORK_MEMORY_ERROR;
        goto exit_level_0;
    }
    /* Call middle-level interface */
    info = LAPACKE_slarfb_work( matrix_order, side, trans, direct, storev, m, n,
                                k, v, ldv, t, ldt, c, ldc, work, ldwork );
    /* Release memory and exit */
    LAPACKE_free( work );
exit_level_0:
    if( info == LAPACK_WORK_MEMORY_ERROR ) {
        LAPACKE_xerbla( "LAPACKE_slarfb", info );
    }
    return info;
}