JNIEXPORT void JNICALL Java_uncomplicate_neanderthal_CBLAS_drotg (JNIEnv *env, jclass clazz, jobject params) { double *ca = (double *) (*env)->GetDirectBufferAddress(env, params); double *cb = ca + 1; double *cc = ca + 2; double *cs = ca + 3; cblas_drotg(ca, cb, cc, cs); };
JNIEXPORT void JNICALL Java_uncomplicate_neanderthal_CBLAS_drotg (JNIEnv *env, jclass clazz, jobject abcs, jint offset_abcs, jint inc_abcs) { double *c_abcs = (double *) (*env)->GetDirectBufferAddress(env, abcs) + offset_abcs; cblas_drotg(c_abcs, c_abcs + inc_abcs, c_abcs + 2 * inc_abcs, c_abcs + 3 * inc_abcs); };
void My_drotg(double* a, double* b, double* c, double* s) { cblas_drotg(a,b,c,s); }
// // Overloaded function for dispatching to // * CBLAS backend, and // * double value-type. // inline void rotg( double& a, double& b, double& c, double& s ) { cblas_drotg( &a, &b, &c, &s ); }
void F77_drotg( double *a, double *b, double *c, double *s) { cblas_drotg(a,b,c,s); return; }
// Given row and column permutations compute the QR decomposition of a // sparse matrix. void sparse_qr_decomp( const int *P1, sparse_mat *A, const int *P2, sparse_mat **Q, sparse_mat **R ) { // Components of the R matrix: int nnz, *is, *js; double *vs; // Allocate structures to store Q and R. sparse_vec **rows = (sparse_vec**)calloc( A->m, sizeof(sparse_vec*) ); rotation *grots = alloc_rotation( A->m ); // Work variables int i, j, *col; double a, b, c, s, r, *val; sparse_vec row, *row_i, *row_j; grots -> n = A -> m; permute_rows(P1, A); permute_cols(A, P2); for( j = 0; j < A->m; ++j ) { row(*A,j,row); row_j = rows[j] = copy_sparse_vec( &row ); if( row_j->nnz > 0 ) { i = *(row_j->is); b = *(row_j->vs); while( i < j ) { row_i = rows[i]; if( row_i->nnz == 0 || *(row_i->is) > i ) a = 0.0; else a = *(row_i->vs); cblas_drotg( &a, &b, &c, &s ); sp_apply_grot( c, s, rows+i, rows+j ); left_comp_rotation( &grots, i, j, c, s ); row_j = rows[j]; if( row_j->nnz == 0 ) break; i = *(row_j->is); b = *(row_j->vs); } } } *Q = sparse_mat_rotation( grots ); *R = sparse_mat_rows( A->n, rows ); free_rotation( grots ); for( j = 0; j < A->m; ++j ) free( rows[j] ); free( rows ); }