#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(
const int argc,
char *
const argv[])
{
const int WANT_VERBOSE = 0;
struct rsb_mtx_t *mtxAp = NULL;
const int br = bs, bc = bs;
int i;
oldnorm = 1.0,
*b1 = NULL, *b2 = NULL,
*bnow = NULL, *bnext = NULL;
size_t ds = 0;
return EXIT_FAILURE;
if(!mtxAp)
return EXIT_FAILURE;
b1 = calloc(1,ds);
b2 = calloc(1,ds);
if(! (b1 && b2))
{
goto err;
}
for( i = 0; i < nrA; ++i )
b1[i] = 1;
bnow = b1, bnext = b2;
while( fabs(norm-oldnorm) > tol && it<maxit )
{
++ it;
oldnorm = norm;
goto err;
norm = 0;
for(i=0;i<nrA;++i)
norm += bnext[i]*bnext[i];
norm = sqrt(norm);
norm = 1.0/norm;
for(i=0;i<nrA;++i)
bnext[i] *= norm;
norm = 1.0/norm;
printf("it:%d norm:%lg norm diff:%lg\n",it,norm,norm-oldnorm);
{void *tmp=bnow;bnow=bnext;bnext=tmp;}
if(WANT_VERBOSE)
{
printf("norm:%lg\n",norm);
if(isinf(norm))
goto err;
for(i=0;i<2;++i)
printf("x[%d]=%lg\n",i,((double*)bnext)[i]);
}
}
free(b1);
free(b2);
goto err;
if( it == maxit )
{
printf("ERROR: hit iterations limit without convergence!");
}
return EXIT_SUCCESS;
err:
return EXIT_FAILURE;
}
auto main() -> int
Definition: assemble.cpp:38
rsb_err_t rsb_spmv(rsb_trans_t transA, const void *alphap, const struct rsb_mtx_t *mtxAp, const void *Xp, rsb_coo_idx_t incX, const void *betap, void *Yp, rsb_coo_idx_t incY)
Definition: rsb_rsb.c:529
rsb_err_t rsb_lib_exit(struct rsb_initopts *iop)
Definition: rsb_rsb.c:202
rsb_err_t rsb_perror(void *stream, rsb_err_t errval)
Definition: rsb_rsb.c:814
struct rsb_mtx_t * rsb_mtx_free(struct rsb_mtx_t *mtxAp)
Definition: rsb_rsb.c:301
rsb_err_t rsb_lib_init(struct rsb_initopts *iop)
Definition: rsb_rsb.c:56
struct rsb_mtx_t * rsb_mtx_alloc_from_coo_const(const void *VA, const rsb_coo_idx_t *IA, const rsb_coo_idx_t *JA, rsb_nnz_idx_t nnzA, rsb_type_t typecode, rsb_coo_idx_t nrA, rsb_coo_idx_t ncA, rsb_blk_idx_t brA, rsb_blk_idx_t bcA, rsb_flags_t flagsA, rsb_err_t *errvalp)
Definition: rsb_rsb.c:240
This file declares the user interface functions and data structures for the librsb library (see The l...
#define RSB_FLAG_NOFLAGS
Definition: rsb.h:478
#define RSB_ERR_NO_ERROR
Definition: rsb.h:616
#define RSB_NULL_EXIT_OPTIONS
Definition: rsb.h:848
#define RSB_DEFAULT_BLOCKING
Definition: rsb.h:429
signed int rsb_nnz_idx_t
Definition: rsb.h:362
signed int rsb_coo_idx_t
Definition: rsb.h:349
#define RSB_ERR_ENOMEM
Definition: rsb.h:637
signed int rsb_err_t
Definition: rsb.h:386
char rsb_type_t
Definition: rsb.h:378
#define RSB_ERR_GENERIC_ERROR
Definition: rsb.h:619
#define RSB_NULL_INIT_OPTIONS
Definition: rsb.h:847
signed int rsb_int_t
Definition: rsb.h:392
#define RSB_TRANSPOSITION_N
N: Non transposed flag, valid for rsb_trans_t typed variables.
Definition: rsb_types.h:138
#define RSB_NUMERICAL_TYPE_FIRST_BLAS
A default numerical matrix type; if possible, not integer one. If no such type is configured in,...
Definition: rsb_types.h:203
#define RSB_DEFAULT_POSSIBLY_FIRST_BLAS_TYPE
The default, blas if possible , numerical type (can be used for declarations).
Definition: rsb_types.h:75