bool solve(const_Matrix<T, Block0> b, Matrix<T, Block1> x) { typedef typename Block_layout<Block0>::order_type order_type; typedef typename Block_layout<Block0>::complex_type complex_type; typedef Layout<2, order_type, Stride_unit_dense, complex_type> data_LP; typedef Strided<2, T, data_LP, Local_map> block_type; assert(b.size(0) == length_); assert(b.size(0) == x.size(0) && b.size(1) == x.size(1)); Matrix<T, block_type> b_int(b.size(0), b.size(1)); assign_local(b_int, b); if (tr == mat_conj || (tr == mat_trans && Is_complex<T>::value) || (tr == mat_herm && !Is_complex<T>::value)) VSIP_IMPL_THROW(unimplemented( "LU solver (CVSIP backend) does not implement this transformation")); { Ext_data<block_type> b_ext(b_int.block()); cvsip::View<2,T,true> cvsip_b_int(b_ext.data(),0,b_ext.stride(0),b_ext.size(0), b_ext.stride(1),b_ext.size(1)); cvsip_b_int.block().admit(true); traits::lu_solve(lu_, tr, cvsip_b_int.ptr()); cvsip_b_int.block().release(true); } assign_local(x, b_int); return true; }
Workblock create_workblock(int times) { Workblock block; int status = alf_wb_create(task_, ALF_WB_MULTI, times, &block.workblock_); if (status != 0) VSIP_IMPL_THROW(std::runtime_error("Task::create_workblock(multi) -- alf_wb_create failed.")); return block; }
Workblock create_workblock() { Workblock block; int status = alf_wb_create(task_, ALF_WB_SINGLE, 1, &block.workblock_); if (status != 0) VSIP_IMPL_THROW(std::runtime_error("Task::create_workblock(single) -- alf_wb_create failed.")); return block; }
extern "C" ALF_ERR_POLICY_T error_handler(void */*context*/, ALF_ERR_TYPE_T type, int code, char *msg) { // For now, we raise unconditionally raise an exception. // This may be refined, for example by chosing different exception // types depending on 'type' above. switch (type) { default: VSIP_IMPL_THROW(runtime_error(code, msg)); } // Unreachable return ALF_ERR_POLICY_ABORT; }
static qr_type *qr_create(length_type n, length_type m, storage_type s) { qr_type *qr = vsip_cqrd_create_f(n, m, storage(s)); if (!qr) VSIP_IMPL_THROW(std::bad_alloc()); return qr; }
static lud_type *lu_create(length_type n) { lud_type *s = vsip_clud_create_f(n); if (!s) VSIP_IMPL_THROW(std::bad_alloc()); return s; }
static chol_type *chol_create(length_type n, mat_uplo ul) { chol_type *s = vsip_chold_create_f(ul == 0 ? VSIP_TR_LOW : VSIP_TR_UPP, n); if (!s) VSIP_IMPL_THROW(std::bad_alloc()); return s; }
static scalar_type const *get_imag_ptr(const_type /*ptr*/) { VSIP_IMPL_THROW(std::runtime_error("Accessing imaginary part of non-complex pointer")); return 0; }