本文整理汇总了C++中BASKER_MATRIX::val方法的典型用法代码示例。如果您正苦于以下问题:C++ BASKER_MATRIX::val方法的具体用法?C++ BASKER_MATRIX::val怎么用?C++ BASKER_MATRIX::val使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BASKER_MATRIX
的用法示例。
在下文中一共展示了BASKER_MATRIX::val方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
BASKER_INLINE
int Basker<Int, Entry, Exe_Space>::upper_tri_solve
(
BASKER_MATRIX &M,
ENTRY_1DARRAY x,
ENTRY_1DARRAY y
)
{
const Int bcol = M.scol;
const Int brow = M.srow;
//printf("Upper Tri Solve, scol: %d ncol: %d \n",
// M.scol, M.ncol);
//end over all columns
for(Int k = M.ncol; k >= 1; k--)
{
//printf("Upper Tri Solve: k: %d \n", k);
#ifdef BASKER_DEBUG_SOLVE_RHS
BASKER_ASSERT(M.val[M.col_ptr[k]-1]!=0.0,"UpperPivot\n");
#endif
//if(M.val[M.col_ptr[k]-1]==0.0)
if(M.val(M.col_ptr(k)-1)==0)
{
printf("Upper pivot: %d %f \n",
M.row_idx[M.col_ptr[k]-1],
M.val[M.col_ptr[k]-1]);
return -1;
}
//printf("TEST, k: %d out: %f in: %f pivot: %f\n",
// k, y[k+bcol-1], x[k+bcol-1],
// M.val[M.col_ptr[k]-1]);
//Comeback and do with and entry divide
//y[k+bcol-1] = x[k+bcol-1] / M.val[M.col_ptr[k]-1];
y(k+brow-1) = x(k+bcol-1) / M.val(M.col_ptr(k)-1);
//for(Int i = M.col_ptr[k]-2; i >= M.col_ptr[k-1]; i--)
for(Int i = M.col_ptr(k)-2; i >= M.col_ptr(k-1); --i)
{
//Int j = M.row_idx[i];
const Int j = M.row_idx(i);
// printf("Updating row_idx: %d %f %f \n",
// j, x[j], M.val[i]*y[k+bcol-1]);
//x[j] -= M.val[i]*y[k+bcol-1];
x(j+brow) -= M.val(i) * y(k+bcol-1);
}
}//end over all columns
return 0;
}//end upper_tri_solve
示例2: col
BASKER_INLINE
int Basker<Int, Entry, Exe_Space>::permute_col
(
BASKER_MATRIX &M,
INT_1DARRAY col
)
{
if((M.ncol == 0)||(M.nnz == 0))
return 0;
Int n = M.ncol;
Int nnz = M.nnz;
//printf("Using n: %d nnz: %d \n", n, nnz);
INT_1DARRAY temp_p;
MALLOC_INT_1DARRAY(temp_p, n+1);
init_value(temp_p, n+1, (Int)0);
INT_1DARRAY temp_i;
MALLOC_INT_1DARRAY(temp_i, nnz);
init_value(temp_i, nnz, (Int)0);
ENTRY_1DARRAY temp_v;
MALLOC_ENTRY_1DARRAY(temp_v, nnz);
init_value(temp_v, nnz, (Entry)0.0);
//printf("done with init \n");
//Determine column ptr of output matrix
for(Int j = 0; j < n; j++)
{
Int i = col (j);
temp_p (i+1) = M.col_ptr (j+1) - M.col_ptr (j);
}
//Get ptrs from lengths
temp_p (0) = 0;
for(Int j = 0; j < n; j++)
{
temp_p (j+1) = temp_p (j+1) + temp_p (j);
}
//copy idxs
for(Int ii = 0; ii < n; ii++)
{
Int ko = temp_p (col (ii) );
for(Int k = M.col_ptr (ii); k < M.col_ptr (ii+1); k++)
{
temp_i (ko) = M.row_idx (k);
temp_v (ko) = M.val (k);
ko++;
}
}
//copy back int A
for(Int ii=0; ii < n+1; ii++)
{
M.col_ptr (ii) = temp_p (ii);
}
for(Int ii=0; ii < nnz; ii++)
{
M.row_idx (ii) = temp_i (ii);
M.val (ii) = temp_v (ii);
}
FREE_INT_1DARRAY(temp_p);
FREE_INT_1DARRAY(temp_i);
FREE_ENTRY_1DARRAY(temp_v);
return 0;
}//end permute_col(int)
示例3: if
BASKER_INLINE
void BaskerMatrix<Int,Entry,Exe_Space>::convert2D
(
BASKER_MATRIX &M,
BASKER_BOOL alloc,
Int kid
)
{
if(nnz == 0)
{
for(Int i = 0; i < ncol+1; i++)
{
col_ptr(i) = 0;
}
MALLOC_INT_1DARRAY(row_idx, 1);
row_idx(0) = (Int) 0;
MALLOC_ENTRY_1DARRAY(val, 1);
val(0) = (Entry) 0;
return;
}
//info();
//We could check some flag ??
//We assume a pre-scan has already happened
if(alloc == BASKER_TRUE)
{
//printf("ALLOC\n");
if(nnz > 0)
{
BASKER_ASSERT(nnz > 0, "matrix row nnz 2");
MALLOC_INT_1DARRAY(row_idx, nnz);
}
else if(nnz ==0)
{
BASKER_ASSERT((nnz+1)>0, "matrix row nnz 3");
MALLOC_INT_1DARRAY(row_idx, nnz+1);
}
}
//init_value(row_idx, nnz, (Int) 0);
//printf("clear row: %d \n", nnz);
for(Int i = 0; i < nnz; ++i)
{
//printf("clear row_idx(%d) \n", i);
row_idx(i) = 0;
}
if(alloc == BASKER_TRUE)
{
if(nnz > 0)
{
BASKER_ASSERT(nnz > 0, "matrix nnz 4");
MALLOC_ENTRY_1DARRAY(val, nnz);
}
else if(nnz == 0)
{
BASKER_ASSERT((nnz+1) > 0, "matrix nnz 5");
MALLOC_ENTRY_1DARRAY(val, nnz+1);
}
}
//init_value(val, nnz, (Entry) 0);
for(Int i = 0; i < nnz; ++i)
{
val(i) = 0;
}
Int temp_count = 0;
for(Int k = scol; k < scol+ncol; ++k)
{
//note col_ptr[k-scol] contains the starting index
if(col_ptr(k-scol) == BASKER_MAX_IDX)
{
col_ptr(k-scol) = temp_count;
//printf("continue called, k: %d \n", k);
continue;
}
for(Int i = col_ptr(k-scol); i < M.col_ptr(k+1); i++)
{
Int j = M.row_idx(i);
//printf("i: %d j:%d \n", i,j);
if(j >= srow+nrow)
{
break;
}
//printf("writing row_dix: %d i: %d val: %d nnz: %d srow: %d nrow: %d \n",
// temp_count, i, j, nnz,
// srow, nrow);
//BASKER_ASSERT(temp_count < nnz, "2DConvert, too many values");
//row_idx[temp_count] = j;
if(j-srow <0)
{
std::cout << "kid: " << kid
<< " j: " << j
<< " srow: " << srow
<< " k: " << k
<< " idx: " << i
//.........这里部分代码省略.........
示例4: if
//.........这里部分代码省略.........
//#ifdef BASKER_DEBUG_ORDER_BTF
printf("Done finding BTF2 cut. Cut size: %d scol: %d \n",
t_size, scol);
printf("Done finding BTF2 cut. blk_idx: %d \n",
blk_idx);
//BASKER_ASSERT(t_size > 0, "BTF CUT SIZE NOT BIG ENOUGH\n");
BASKER_ASSERT((scol >= 0) && (scol < M.ncol), "SCOL\n");
//#endif
//Comeback and change
btf_tabs_offset = blk_idx;
//2. Move into Blocks
if(btf_tabs_offset != 0)
{
//--Move A into BTF_A;
BTF_A.set_shape(0, scol, 0, scol);
BTF_A.nnz = M.col_ptr(scol);
#ifdef BASKER_DEBUG_ORDER_BTF
printf("Init BTF_A. ncol: %d nnz: %d \n",
scol, BTF_A.nnz);
#endif
if(BTF_A.v_fill == BASKER_FALSE)
{
BASKER_ASSERT(BTF_A.ncol >= 0, "BTF_A, col_ptr");
MALLOC_INT_1DARRAY(BTF_A.col_ptr, BTF_A.ncol+1);
BASKER_ASSERT(BTF_A.nnz > 0, "BTF_A, nnz");
MALLOC_INT_1DARRAY(BTF_A.row_idx, BTF_A.nnz);
MALLOC_ENTRY_1DARRAY(BTF_A.val, BTF_A.nnz);
BTF_A.fill();
}
Int annz = 0;
for(Int k = 0; k < scol; ++k)
{
#ifdef BASKER_DEBUG_ORDER_BTF
printf("copy column: %d into A_BTF, [%d %d] \n",
k, M.col_ptr(k), M.col_ptr(k+1));
#endif
for(Int i = M.col_ptr(k); i < M.col_ptr(k+1); ++i)
{
//printf("annz: %d i: %d \n", annz, i);
BTF_A.row_idx(annz) = M.row_idx(i);
BTF_A.val(annz) = M.val(i);
annz++;
}
BTF_A.col_ptr(k+1) = annz;
}
}//no A
//Fill in B and C at the same time
INT_1DARRAY cws;
BASKER_ASSERT((M.ncol-scol+1) > 0, "BTF_SIZE MALLOC");
MALLOC_INT_1DARRAY(cws, M.ncol-scol+1);
init_value(cws, M.ncol-scol+1, (Int)M.ncol);
BTF_B.set_shape(0 , scol,
scol, M.ncol-scol);
BTF_C.set_shape(scol, M.ncol-scol,
示例5: printf
//.........这里部分代码省略.........
}
}//end while(move_fwd)
#ifdef BASKER_DEBUG_ORDER_BTF
printf("Done finding BTF cut. Cut size: %d scol: %d \n",
t_size, scol);
//BASKER_ASSERT(t_size > 0, "BTF CUT SIZE NOT BIG ENOUGH\n");
BASKER_ASSERT((scol >= 0) && (scol < M.ncol), "SCOL\n");
#endif
//Comeback and change
btf_tabs_offset = blk_idx;
//2. Move into Blocks
if(btf_tabs_offset != 0)
{
//--Move A into BTF_A;
BTF_A.set_shape(0, scol, 0, scol);
BTF_A.nnz = M.col_ptr(scol);
#ifdef BASKER_DEBUG_ORDER_BTF
printf("Init BTF_A. ncol: %d nnz: %d \n",
scol, BTF_A.nnz);
#endif
if(BTF_A.v_fill == BASKER_FALSE)
{
BASKER_ASSERT(BTF_A.ncol >= 0, "BTF_A, col_ptr");
MALLOC_INT_1DARRAY(BTF_A.col_ptr, BTF_A.ncol+1);
BASKER_ASSERT(BTF_A.nnz > 0, "BTF_A, nnz");
MALLOC_INT_1DARRAY(BTF_A.row_idx, BTF_A.nnz);
MALLOC_ENTRY_1DARRAY(BTF_A.val, BTF_A.nnz);
BTF_A.fill();
}
Int annz = 0;
for(Int k = 0; k < scol; ++k)
{
#ifdef BASKER_DEBUG_ORDER_BTF
printf("copy column: %d into A_BTF, [%d %d] \n",
k, M.col_ptr(k), M.col_ptr(k+1));
#endif
for(Int i = M.col_ptr(k); i < M.col_ptr(k+1); ++i)
{
//printf("annz: %d i: %d \n", annz, i);
BTF_A.row_idx(annz) = M.row_idx(i);
BTF_A.val(annz) = M.val(i);
annz++;
}
BTF_A.col_ptr(k+1) = annz;
}
}//no A
//Fill in B and C at the same time
INT_1DARRAY cws;
BASKER_ASSERT((M.ncol-scol+1) > 0, "BTF_SIZE MALLOC");
MALLOC_INT_1DARRAY(cws, M.ncol-scol+1);
init_value(cws, M.ncol-scol+1, (Int)M.ncol);
BTF_B.set_shape(0 , scol,
scol, M.ncol-scol);
BTF_C.set_shape(scol, M.ncol-scol,