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; }
static LLVMValueRef assign_rvalue(compile_t* c, ast_t* left, ast_t* r_type, LLVMValueRef r_value) { switch(ast_id(left)) { case TK_SEQ: // The actual expression is inside a sequence node. while(ast_id(left) == TK_SEQ) { assert(ast_childcount(left) == 1); left = ast_child(left); } return assign_rvalue(c, left, r_type, r_value); case TK_VAR: case TK_LET: { // Generate the locals. if(gen_localdecl(c, left) == NULL) return NULL; return assign_rvalue(c, ast_child(left), r_type, r_value); } case TK_FVARREF: case TK_FLETREF: { // The result is the previous value of the field. LLVMValueRef l_value = gen_fieldptr(c, left); ast_t* p_type = ast_type(ast_child(left)); return assign_field(c, l_value, r_value, p_type, r_type); } case TK_EMBEDREF: { // Do nothing. The embed field was already passed as the receiver. return GEN_NOVALUE; } case TK_VARREF: { // The result is the previous value of the local. const char* name = ast_name(ast_child(left)); codegen_local_lifetime_start(c, name); LLVMValueRef l_value = codegen_getlocal(c, name); LLVMValueRef ret = assign_local(c, l_value, r_value, r_type); return ret; } case TK_TUPLE: { // If the l_value is a tuple, assemble it as the result. LLVMValueRef result = gen_expr(c, left); if(result == NULL) return NULL; if(!assign_tuple(c, left, r_type, r_value)) return NULL; // Return the original tuple. return result; } case TK_ID: { // We may have recursed here from a VAR or LET or arrived directly. const char* name = ast_name(left); codegen_local_lifetime_start(c, name); LLVMValueRef l_value = codegen_getlocal(c, name); LLVMValueRef ret = assign_local(c, l_value, r_value, r_type); return ret; } default: {} } assert(0); return NULL; }