我正在使用通过macports安装的SuiteSparse @4.2.1_3,并希望分配一个cholmod_dense结构。考虑下面这段代码:
/* start CHOLMOD */
cholmod_common c;
cholmod_dense* myv;
cholmod_dense* myv2;
cholmod_start (&c);
myv = cholmod_l_allocate_dense( 4,1,4,CHOLMOD_REAL,&c);
myv2 = cholmod_allocate_dense(4,1,4,CHOLMOD_REAL,&c);
printf("myv=%pn",myv);
printf("myv2=%pn",myv2);
/* finish CHOLMOD */
cholmod_finish (&c) ;
得到以下输出:
myv=0x0
myv2=0x7fb86ac0c060
这意味着在长版本中分配cholmod_dense
结构不工作,但在整数版本中工作得很好。有人知道为什么会这样吗?
您必须在cholmod_common
结构c
中设置正确的类型。
c.itype=CHOLMOD_LONG;
/* Common->itype and Common->dtype are used to define the types of all
* sparse matrices, triplet matrices, dense matrices, and factors
* created using this Common struct. The itypes and dtypes of all
* parameters to all CHOLMOD routines must match. */