本文整理汇总了C++中BASKER_MATRIX::row_idx方法的典型用法代码示例。如果您正苦于以下问题:C++ BASKER_MATRIX::row_idx方法的具体用法?C++ BASKER_MATRIX::row_idx怎么用?C++ BASKER_MATRIX::row_idx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BASKER_MATRIX
的用法示例。
在下文中一共展示了BASKER_MATRIX::row_idx方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: printf
BASKER_FINLINE
void Basker<Int, Entry,Exe_Space>::csymamd_order
(
BASKER_MATRIX &M,
INT_1DARRAY p,
INT_1DARRAY cmember
)
{
amd_flag = BASKER_TRUE;
//Debug,
#ifdef BASKER_DEBUG_ORDER_AMD
printf("cmember: \n");
for(Int i = 0; i < M.ncol; ++i)
{
printf("(%d, %d), ", i, cmember(i));
}
printf("\n");
#endif
//If doing iluk, we will not want this.
//See amd blk notes
if(Options.incomplete == BASKER_TRUE)
{
for(Int i = 0; i < M.ncol; i++)
{
p(i) = i;
}
//printf("Short csym \n");
return;
}
INT_1DARRAY temp_p;
BASKER_ASSERT(M.ncol > 0, "AMD perm not long enough");
MALLOC_INT_1DARRAY(temp_p, M.ncol+1);
init_value(temp_p, M.ncol+1, (Int) 0);
my_amesos_csymamd(M.ncol, &(M.col_ptr(0)), &(M.row_idx(0)),
&(temp_p(0)), &(cmember(0)));
for(Int i = 0; i < M.ncol; ++i)
{
p(temp_p(i)) = i;
}
}//end csymamd()
示例3:
BASKER_FINLINE
void Basker<Int,Entry,Exe_Space>::amd_order
(
BASKER_MATRIX &M,
INT_1DARRAY p
)
{
double amd_info[AMD_INFO];
amesos_amd(M.ncol, &(M.col_ptr(0)),
&(M.row_idx(0)), &(p(0)),
NULL, amd_info);
}//end amd_order()
示例4: fopen
BASKER_INLINE
int Basker<Int, Entry, Exe_Space>::strong_component
(
BASKER_MATRIX &M,
Int &nblks,
INT_1DARRAY &perm,
INT_1DARRAY &CC
)
{
typedef long int l_int;
INT_1DARRAY perm_in;
MALLOC_INT_1DARRAY(perm_in, M.ncol);
MALLOC_INT_1DARRAY(perm, M.ncol);
//JDB:Note, this needs to be changed just fixed for int/long
MALLOC_INT_1DARRAY(CC, M.ncol+1);
for(l_int i = 0; i < M.ncol; i++)
{
perm_in(i) = i;
}
//printf("SC one \n");
//my_strong_component(M,nblks,perm,perm_in, CC);
BaskerSSWrapper<Int>::my_strong_component(M.ncol,
&(M.col_ptr(0)),
&(M.row_idx(0)),
nblks,
&(perm(0)),
&(perm_in(0)),
&(CC(0)));
#ifdef BASKER_DEBUG_ORDER_BTF
FILE *fp;
fp = fopen("btf.txt", "w");
for(Int i = 0; i < M.ncol; i++)
{
fprintf(fp, "%d \n", perm(i));
}
fclose(fp);
#endif
//printf("FOUND NBLKS: %d \n", nblks);
return 0;
}//end strong_component <long int>
示例5: printf
BASKER_FINLINE
void Basker<Int, Entry,Exe_Space>::csymamd_order
(
BASKER_MATRIX &M,
INT_1DARRAY p,
INT_1DARRAY cmember
)
{
amd_flag = BASKER_TRUE;
//Debug,
#ifdef BASKER_DEBUG_ORDER_AMD
printf("cmember: \n");
for(Int i = 0; i < M.ncol; ++i)
{
printf("(%d, %d), ", i, cmember(i));
}
printf("\n");
#endif
INT_1DARRAY temp_p;
BASKER_ASSERT(M.ncol > 0, "AMD perm not long enough");
MALLOC_INT_1DARRAY(temp_p, M.ncol+1);
init_value(temp_p, M.ncol+1, (Int) 0);
my_amesos_csymamd(M.ncol, &(M.col_ptr(0)), &(M.row_idx(0)),
&(temp_p(0)), &(cmember(0)));
for(Int i = 0; i < M.ncol; ++i)
{
p(temp_p(i)) = i;
}
}//end csymamd()
示例6: 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)
示例7: 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
//.........这里部分代码省略.........
示例8: 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);
示例9: printf
//.........这里部分代码省略.........
move_fwd = BASKER_FALSE;
}
}//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);
示例10: p
void Basker<Int,Entry,Exe_Space>::btf_blk_amd
(
BASKER_MATRIX &M,
INT_1DARRAY p,
INT_1DARRAY btf_nnz,
INT_1DARRAY btf_work
)
{
// printf("=============BTF_BLK_AMD_CALLED========\n");
if(Options.incomplete == BASKER_TRUE)
{
//We note that AMD on incomplete ILUK
//Seems realy bad and leads to a zero on the diag
//Therefore, we simply return the natural ordering
for(Int i = 0 ; i < M.ncol; i++)
{
p(i) = i;
}
//We will makeup work to be 1,
//Since BTF is not supported in our iluk
for(Int b = 0; b < btf_nblks; b++)
{
btf_nnz(b) = 1;
btf_work(b) =1;
}
//printf("Short amd blk\n");
return;
}
//p == length(M)
//Scan over all blks
//Note, that this needs to be made parallel in the
//future (Future Josh will be ok with this, right?)
//This is a horrible way to do this!!!!!
//KLU does this very nice, but they also make all the little blks
INT_1DARRAY temp_col;
MALLOC_INT_1DARRAY(temp_col, M.ncol+1);
INT_1DARRAY temp_row;
MALLOC_INT_1DARRAY(temp_row, M.nnz);
//printf("Done with btf_blk_amd malloc \n");
//printf("blks: %d \n" , btf_nblks);
for(Int b = 0; b < btf_nblks; b++)
{
Int blk_size = btf_tabs(b+1) - btf_tabs(b);
//printf("blk: %d blk_size: %d \n",
// b, blk_size);
if(blk_size < 3)
{
//printf("debug, blk_size: %d \n", blk_size);
for(Int ii = 0; ii < blk_size; ++ii)
{
//printf("set %d \n", btf_tabs(b)+ii-M.scol);
p(ii+btf_tabs(b)) = btf_tabs(b)+ii-M.scol;
}
btf_work(b) = blk_size*blk_size*blk_size;
btf_nnz(b) = (.5*(blk_size*blk_size) + blk_size);
continue;
}
INT_1DARRAY tempp;
MALLOC_INT_1DARRAY(tempp, blk_size+1);
//Fill in temp matrix
Int nnz = 0;
Int column = 1;
temp_col(0) = 0;
for(Int k = btf_tabs(b); k < btf_tabs(b+1); k++)
{
for(Int i = M.col_ptr(k); i < M.col_ptr(k+1); i++)
{
if(M.row_idx(i) < btf_tabs(b))
continue;
temp_row(nnz) = M.row_idx(i) - btf_tabs(b);
nnz++;
}// end over all row_idx
temp_col(column) = nnz;
column++;
}//end over all columns k
#ifdef BASKER_DEBUG_ORDER_AMD
printf("col_ptr: ");
for(Int i = 0 ; i < blk_size+1; i++)
{
printf("%d, ", temp_col(i));
}
printf("\n");
printf("row_idx: ");
//.........这里部分代码省略.........