Example #1
0
File: ffb_vb.c Project: aosm/X11
static void init_setup_tab( void )
{
	init_w();
	init_g();
	init_wg();
	init_t();
	init_wt();
	init_gt();
	init_wgt();
}
main()
{
    GUSANO *g;
    int i,j;
    int dir = 1; /* 0: N, 1: E, 2: S, 3: W */
    char s[200];

    srandom(time(NULL));

    for(i=0; i<MAXX/GORDO; i++)
        for(j=0; j<MAXY/GORDO; j++)
            tablero[i][j] = 0;

    init_w(MAXX, MAXY);

    g = init_g(MAXX/2, MAXY/2, dir, 4); /* x,y,dir,largo */
    if(!galleta_id) cookie(MAXX, MAXY);

    for(;;) {
        usleep(100000);
        switch(getchar()) {
        case 'h': /* back */
            dir = 3;
            break;
        case 'j': /* down */
            dir = 2;
            break;
        case 'k': /* up */
            dir = 0;
            break;
        case 'l': /* forward */
            dir = 1;
            break;
        case EOF:
            goto fin;
            break;
        default:
            continue;
            break;
        }
        g->dir = dir;
        if( !move_g(g) ) {
fin:
            sprintf(s, "Boing!!, score = %d", size_l(g->cuerpo));
            free_g(g);
            close_w(s, 100, 100);
            exit(0);
        }
    }
}
Example #3
0
int main(void)
{
    /* Local scalars */
    char job, job_i;
    char compz, compz_i;
    lapack_int n, n_i;
    lapack_int ilo, ilo_i;
    lapack_int ihi, ihi_i;
    lapack_int ldh, ldh_i;
    lapack_int ldh_r;
    lapack_int ldz, ldz_i;
    lapack_int ldz_r;
    lapack_int lwork, lwork_i;
    lapack_int info, info_i;
    lapack_int i;
    int failed;

    /* Local arrays */
    lapack_complex_float *h = NULL, *h_i = NULL;
    lapack_complex_float *w = NULL, *w_i = NULL;
    lapack_complex_float *z = NULL, *z_i = NULL;
    lapack_complex_float *work = NULL, *work_i = NULL;
    lapack_complex_float *h_save = NULL;
    lapack_complex_float *w_save = NULL;
    lapack_complex_float *z_save = NULL;
    lapack_complex_float *h_r = NULL;
    lapack_complex_float *z_r = NULL;

    /* Iniitialize the scalar parameters */
    init_scalars_chseqr( &job, &compz, &n, &ilo, &ihi, &ldh, &ldz, &lwork );
    ldh_r = n+2;
    ldz_r = n+2;
    job_i = job;
    compz_i = compz;
    n_i = n;
    ilo_i = ilo;
    ihi_i = ihi;
    ldh_i = ldh;
    ldz_i = ldz;
    lwork_i = lwork;

    /* Allocate memory for the LAPACK routine arrays */
    h = (lapack_complex_float *)
        LAPACKE_malloc( ldh*n * sizeof(lapack_complex_float) );
    w = (lapack_complex_float *)
        LAPACKE_malloc( n * sizeof(lapack_complex_float) );
    z = (lapack_complex_float *)
        LAPACKE_malloc( ldz*n * sizeof(lapack_complex_float) );
    work = (lapack_complex_float *)
        LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );

    /* Allocate memory for the C interface function arrays */
    h_i = (lapack_complex_float *)
        LAPACKE_malloc( ldh*n * sizeof(lapack_complex_float) );
    w_i = (lapack_complex_float *)
        LAPACKE_malloc( n * sizeof(lapack_complex_float) );
    z_i = (lapack_complex_float *)
        LAPACKE_malloc( ldz*n * sizeof(lapack_complex_float) );
    work_i = (lapack_complex_float *)
        LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );

    /* Allocate memory for the backup arrays */
    h_save = (lapack_complex_float *)
        LAPACKE_malloc( ldh*n * sizeof(lapack_complex_float) );
    w_save = (lapack_complex_float *)
        LAPACKE_malloc( n * sizeof(lapack_complex_float) );
    z_save = (lapack_complex_float *)
        LAPACKE_malloc( ldz*n * sizeof(lapack_complex_float) );

    /* Allocate memory for the row-major arrays */
    h_r = (lapack_complex_float *)
        LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
    z_r = (lapack_complex_float *)
        LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );

    /* Initialize input arrays */
    init_h( ldh*n, h );
    init_w( n, w );
    init_z( ldz*n, z );
    init_work( lwork, work );

    /* Backup the ouptut arrays */
    for( i = 0; i < ldh*n; i++ ) {
        h_save[i] = h[i];
    }
    for( i = 0; i < n; i++ ) {
        w_save[i] = w[i];
    }
    for( i = 0; i < ldz*n; i++ ) {
        z_save[i] = z[i];
    }

    /* Call the LAPACK routine */
    chseqr_( &job, &compz, &n, &ilo, &ihi, h, &ldh, w, z, &ldz, work, &lwork,
             &info );

    /* Initialize input data, call the column-major middle-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < ldh*n; i++ ) {
        h_i[i] = h_save[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < ldz*n; i++ ) {
        z_i[i] = z_save[i];
    }
    for( i = 0; i < lwork; i++ ) {
        work_i[i] = work[i];
    }
    info_i = LAPACKE_chseqr_work( LAPACK_COL_MAJOR, job_i, compz_i, n_i, ilo_i,
                                  ihi_i, h_i, ldh_i, w_i, z_i, ldz_i, work_i,
                                  lwork_i );

    failed = compare_chseqr( h, h_i, w, w_i, z, z_i, info, info_i, compz, ldh,
                             ldz, n );
    if( failed == 0 ) {
        printf( "PASSED: column-major middle-level interface to chseqr\n" );
    } else {
        printf( "FAILED: column-major middle-level interface to chseqr\n" );
    }

    /* Initialize input data, call the column-major high-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < ldh*n; i++ ) {
        h_i[i] = h_save[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < ldz*n; i++ ) {
        z_i[i] = z_save[i];
    }
    for( i = 0; i < lwork; i++ ) {
        work_i[i] = work[i];
    }
    info_i = LAPACKE_chseqr( LAPACK_COL_MAJOR, job_i, compz_i, n_i, ilo_i,
                             ihi_i, h_i, ldh_i, w_i, z_i, ldz_i );

    failed = compare_chseqr( h, h_i, w, w_i, z, z_i, info, info_i, compz, ldh,
                             ldz, n );
    if( failed == 0 ) {
        printf( "PASSED: column-major high-level interface to chseqr\n" );
    } else {
        printf( "FAILED: column-major high-level interface to chseqr\n" );
    }

    /* Initialize input data, call the row-major middle-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < ldh*n; i++ ) {
        h_i[i] = h_save[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < ldz*n; i++ ) {
        z_i[i] = z_save[i];
    }
    for( i = 0; i < lwork; i++ ) {
        work_i[i] = work[i];
    }

    LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, h_i, ldh, h_r, n+2 );
    if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
        LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, z_i, ldz, z_r, n+2 );
    }
    info_i = LAPACKE_chseqr_work( LAPACK_ROW_MAJOR, job_i, compz_i, n_i, ilo_i,
                                  ihi_i, h_r, ldh_r, w_i, z_r, ldz_r, work_i,
                                  lwork_i );

    LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, h_r, n+2, h_i, ldh );
    if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
        LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, z_r, n+2, z_i, ldz );
    }

    failed = compare_chseqr( h, h_i, w, w_i, z, z_i, info, info_i, compz, ldh,
                             ldz, n );
    if( failed == 0 ) {
        printf( "PASSED: row-major middle-level interface to chseqr\n" );
    } else {
        printf( "FAILED: row-major middle-level interface to chseqr\n" );
    }

    /* Initialize input data, call the row-major high-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < ldh*n; i++ ) {
        h_i[i] = h_save[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < ldz*n; i++ ) {
        z_i[i] = z_save[i];
    }
    for( i = 0; i < lwork; i++ ) {
        work_i[i] = work[i];
    }

    /* Init row_major arrays */
    LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, h_i, ldh, h_r, n+2 );
    if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
        LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, z_i, ldz, z_r, n+2 );
    }
    info_i = LAPACKE_chseqr( LAPACK_ROW_MAJOR, job_i, compz_i, n_i, ilo_i,
                             ihi_i, h_r, ldh_r, w_i, z_r, ldz_r );

    LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, h_r, n+2, h_i, ldh );
    if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
        LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, z_r, n+2, z_i, ldz );
    }

    failed = compare_chseqr( h, h_i, w, w_i, z, z_i, info, info_i, compz, ldh,
                             ldz, n );
    if( failed == 0 ) {
        printf( "PASSED: row-major high-level interface to chseqr\n" );
    } else {
        printf( "FAILED: row-major high-level interface to chseqr\n" );
    }

    /* Release memory */
    if( h != NULL ) {
        LAPACKE_free( h );
    }
    if( h_i != NULL ) {
        LAPACKE_free( h_i );
    }
    if( h_r != NULL ) {
        LAPACKE_free( h_r );
    }
    if( h_save != NULL ) {
        LAPACKE_free( h_save );
    }
    if( w != NULL ) {
        LAPACKE_free( w );
    }
    if( w_i != NULL ) {
        LAPACKE_free( w_i );
    }
    if( w_save != NULL ) {
        LAPACKE_free( w_save );
    }
    if( z != NULL ) {
        LAPACKE_free( z );
    }
    if( z_i != NULL ) {
        LAPACKE_free( z_i );
    }
    if( z_r != NULL ) {
        LAPACKE_free( z_r );
    }
    if( z_save != NULL ) {
        LAPACKE_free( z_save );
    }
    if( work != NULL ) {
        LAPACKE_free( work );
    }
    if( work_i != NULL ) {
        LAPACKE_free( work_i );
    }

    return 0;
}
analysis_list* MFP(flow_list *_flows, int_list *E)
{
	printf("BEGIN MFP\n");
	/*---------------initialisation--------------*/
	flow_list *W = (flow_list *)NULL; //init liste_label
	//init_w
	init_w(&W,_flows);//copie de flows

	//liste Analysis initialisation
	analysis_list *analysis_l = NULL;
	mk_analysis_list(&analysis_l);
	//init_analysis_list(&analysis_l, getFlow());
	//initialisation analysis_list

	flow_list *flcour = W;
	while(flcour != NULL)
	{
		analysis_block *analysis = get_analysis_block(analysis_l, flcour->val->start);
		if(analysis ==NULL)
		{
			mk_analysis_block(&analysis, flcour->val->start);
			add_analysis_list(&analysis_l,analysis);
		}

		if(is_in(flcour->val->start,E))
		{
			//valeur d'initialisation => fonction a définir
			//peut être a partir du block
			analysis->list = init(flcour->val->start);
		}
		else
		{
			//valeur par defaut => fonction aussi a definir
			analysis->list = bottom(flcour->val->start);
		}
		flcour = flcour->next;
	}

	/*------------------------iteration-------------------*/

	flow *cour=NULL;
	while(!isEmpty_flow_list(W))
	{
		cour = pop_flow_list(&W);
		
		//printf("cour: (%d, %d) \n", cour->start, cour->end);

		analysis_block *b1 = get_analysis_block(analysis_l,cour->start);
		analysis_block *b2 = get_analysis_block(analysis_l,cour->end);


		//DEBUG
		if(b1 == NULL) 
		{
			//printf("b1 NULL %d\n", cour->start);
			analysis_block *temp=NULL;
			mk_analysis_block(&temp, cour->start);
			add_analysis_list(&analysis_l,temp);
			b1 = get_analysis_block(analysis_l,cour->start);
		}
		if(b2 == NULL) 
		{
			//printf("b2 NULL %d\n", cour->end);
			analysis_block *temp=NULL;
			mk_analysis_block(&temp, cour->end);
			add_analysis_list(&analysis_l,temp);
			b2 = get_analysis_block(analysis_l,cour->end);
		}

		analysis_block * fb1 = fonction_l(b1);
		if(! MFP_include(fb1, b2))
		{
			//analysis_block *ablock_res = union_analysis_list(b1,b2);
			b2->list = union_int_list(fb1->list, b2->list);
			//TODO => verifier ce qui se passe en memoire
			//changement d'affectation de 
			//affect_analysis(analysis_union(b1,b2));
		
			//ajout des chemins depuis "end"
			flcour = _flows;
			while(flcour != NULL)
			{
				if(flcour->val->start == cour->end)
				{
					//ajout de flow fcour
					if(! contains(flcour->val, W))
					{
						W=mk_flow_list(flcour->val,W);
					}
				}
				flcour = flcour->next;
			}
		}
		if (fb1 !=NULL) free(fb1);
	}

	/*------------------- resultat ------------------------------*/

	//printf("Fin itérations\n");
	//inutile ici, vu que l'on travaille avec une seule liste
	//printf("END MFP\n");
	return analysis_l;
}
Example #5
0
int main(void)
{
    /* Local scalars */
    char job, job_i;
    char eigsrc, eigsrc_i;
    char initv, initv_i;
    lapack_int n, n_i;
    lapack_int ldh, ldh_i;
    lapack_int ldh_r;
    lapack_int ldvl, ldvl_i;
    lapack_int ldvl_r;
    lapack_int ldvr, ldvr_i;
    lapack_int ldvr_r;
    lapack_int mm, mm_i;
    lapack_int m, m_i;
    lapack_int info, info_i;
    lapack_int i;
    int failed;

    /* Local arrays */
    lapack_int *select = NULL, *select_i = NULL;
    lapack_complex_double *h = NULL, *h_i = NULL;
    lapack_complex_double *w = NULL, *w_i = NULL;
    lapack_complex_double *vl = NULL, *vl_i = NULL;
    lapack_complex_double *vr = NULL, *vr_i = NULL;
    lapack_complex_double *work = NULL, *work_i = NULL;
    double *rwork = NULL, *rwork_i = NULL;
    lapack_int *ifaill = NULL, *ifaill_i = NULL;
    lapack_int *ifailr = NULL, *ifailr_i = NULL;
    lapack_complex_double *w_save = NULL;
    lapack_complex_double *vl_save = NULL;
    lapack_complex_double *vr_save = NULL;
    lapack_int *ifaill_save = NULL;
    lapack_int *ifailr_save = NULL;
    lapack_complex_double *h_r = NULL;
    lapack_complex_double *vl_r = NULL;
    lapack_complex_double *vr_r = NULL;

    /* Iniitialize the scalar parameters */
    init_scalars_zhsein( &job, &eigsrc, &initv, &n, &ldh, &ldvl, &ldvr, &mm );
    ldh_r = n+2;
    ldvl_r = mm+2;
    ldvr_r = mm+2;
    job_i = job;
    eigsrc_i = eigsrc;
    initv_i = initv;
    n_i = n;
    ldh_i = ldh;
    ldvl_i = ldvl;
    ldvr_i = ldvr;
    mm_i = mm;

    /* Allocate memory for the LAPACK routine arrays */
    select = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
    h = (lapack_complex_double *)
        LAPACKE_malloc( ldh*n * sizeof(lapack_complex_double) );
    w = (lapack_complex_double *)
        LAPACKE_malloc( n * sizeof(lapack_complex_double) );
    vl = (lapack_complex_double *)
        LAPACKE_malloc( ldvl*mm * sizeof(lapack_complex_double) );
    vr = (lapack_complex_double *)
        LAPACKE_malloc( ldvr*mm * sizeof(lapack_complex_double) );
    work = (lapack_complex_double *)
        LAPACKE_malloc( n*n * sizeof(lapack_complex_double) );
    rwork = (double *)LAPACKE_malloc( n * sizeof(double) );
    ifaill = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );
    ifailr = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );

    /* Allocate memory for the C interface function arrays */
    select_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
    h_i = (lapack_complex_double *)
        LAPACKE_malloc( ldh*n * sizeof(lapack_complex_double) );
    w_i = (lapack_complex_double *)
        LAPACKE_malloc( n * sizeof(lapack_complex_double) );
    vl_i = (lapack_complex_double *)
        LAPACKE_malloc( ldvl*mm * sizeof(lapack_complex_double) );
    vr_i = (lapack_complex_double *)
        LAPACKE_malloc( ldvr*mm * sizeof(lapack_complex_double) );
    work_i = (lapack_complex_double *)
        LAPACKE_malloc( n*n * sizeof(lapack_complex_double) );
    rwork_i = (double *)LAPACKE_malloc( n * sizeof(double) );
    ifaill_i = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );
    ifailr_i = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );

    /* Allocate memory for the backup arrays */
    w_save = (lapack_complex_double *)
        LAPACKE_malloc( n * sizeof(lapack_complex_double) );
    vl_save = (lapack_complex_double *)
        LAPACKE_malloc( ldvl*mm * sizeof(lapack_complex_double) );
    vr_save = (lapack_complex_double *)
        LAPACKE_malloc( ldvr*mm * sizeof(lapack_complex_double) );
    ifaill_save = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );
    ifailr_save = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );

    /* Allocate memory for the row-major arrays */
    h_r = (lapack_complex_double *)
        LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_double) );
    vl_r = (lapack_complex_double *)
        LAPACKE_malloc( n*(mm+2) * sizeof(lapack_complex_double) );
    vr_r = (lapack_complex_double *)
        LAPACKE_malloc( n*(mm+2) * sizeof(lapack_complex_double) );

    /* Initialize input arrays */
    init_select( n, select );
    init_h( ldh*n, h );
    init_w( n, w );
    init_vl( ldvl*mm, vl );
    init_vr( ldvr*mm, vr );
    init_work( n*n, work );
    init_rwork( n, rwork );
    init_ifaill( mm, ifaill );
    init_ifailr( mm, ifailr );

    /* Backup the ouptut arrays */
    for( i = 0; i < n; i++ ) {
        w_save[i] = w[i];
    }
    for( i = 0; i < ldvl*mm; i++ ) {
        vl_save[i] = vl[i];
    }
    for( i = 0; i < ldvr*mm; i++ ) {
        vr_save[i] = vr[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifaill_save[i] = ifaill[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifailr_save[i] = ifailr[i];
    }

    /* Call the LAPACK routine */
    zhsein_( &job, &eigsrc, &initv, select, &n, h, &ldh, w, vl, &ldvl, vr,
             &ldvr, &mm, &m, work, rwork, ifaill, ifailr, &info );

    /* Initialize input data, call the column-major middle-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < n; i++ ) {
        select_i[i] = select[i];
    }
    for( i = 0; i < ldh*n; i++ ) {
        h_i[i] = h[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < ldvl*mm; i++ ) {
        vl_i[i] = vl_save[i];
    }
    for( i = 0; i < ldvr*mm; i++ ) {
        vr_i[i] = vr_save[i];
    }
    for( i = 0; i < n*n; i++ ) {
        work_i[i] = work[i];
    }
    for( i = 0; i < n; i++ ) {
        rwork_i[i] = rwork[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifaill_i[i] = ifaill_save[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifailr_i[i] = ifailr_save[i];
    }
    info_i = LAPACKE_zhsein_work( LAPACK_COL_MAJOR, job_i, eigsrc_i, initv_i,
                                  select_i, n_i, h_i, ldh_i, w_i, vl_i, ldvl_i,
                                  vr_i, ldvr_i, mm_i, &m_i, work_i, rwork_i,
                                  ifaill_i, ifailr_i );

    failed = compare_zhsein( w, w_i, vl, vl_i, vr, vr_i, m, m_i, ifaill,
                             ifaill_i, ifailr, ifailr_i, info, info_i, job,
                             ldvl, ldvr, mm, n );
    if( failed == 0 ) {
        printf( "PASSED: column-major middle-level interface to zhsein\n" );
    } else {
        printf( "FAILED: column-major middle-level interface to zhsein\n" );
    }

    /* Initialize input data, call the column-major high-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < n; i++ ) {
        select_i[i] = select[i];
    }
    for( i = 0; i < ldh*n; i++ ) {
        h_i[i] = h[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < ldvl*mm; i++ ) {
        vl_i[i] = vl_save[i];
    }
    for( i = 0; i < ldvr*mm; i++ ) {
        vr_i[i] = vr_save[i];
    }
    for( i = 0; i < n*n; i++ ) {
        work_i[i] = work[i];
    }
    for( i = 0; i < n; i++ ) {
        rwork_i[i] = rwork[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifaill_i[i] = ifaill_save[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifailr_i[i] = ifailr_save[i];
    }
    info_i = LAPACKE_zhsein( LAPACK_COL_MAJOR, job_i, eigsrc_i, initv_i,
                             select_i, n_i, h_i, ldh_i, w_i, vl_i, ldvl_i, vr_i,
                             ldvr_i, mm_i, &m_i, ifaill_i, ifailr_i );

    failed = compare_zhsein( w, w_i, vl, vl_i, vr, vr_i, m, m_i, ifaill,
                             ifaill_i, ifailr, ifailr_i, info, info_i, job,
                             ldvl, ldvr, mm, n );
    if( failed == 0 ) {
        printf( "PASSED: column-major high-level interface to zhsein\n" );
    } else {
        printf( "FAILED: column-major high-level interface to zhsein\n" );
    }

    /* Initialize input data, call the row-major middle-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < n; i++ ) {
        select_i[i] = select[i];
    }
    for( i = 0; i < ldh*n; i++ ) {
        h_i[i] = h[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < ldvl*mm; i++ ) {
        vl_i[i] = vl_save[i];
    }
    for( i = 0; i < ldvr*mm; i++ ) {
        vr_i[i] = vr_save[i];
    }
    for( i = 0; i < n*n; i++ ) {
        work_i[i] = work[i];
    }
    for( i = 0; i < n; i++ ) {
        rwork_i[i] = rwork[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifaill_i[i] = ifaill_save[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifailr_i[i] = ifailr_save[i];
    }

    LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, h_i, ldh, h_r, n+2 );
    if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
        LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, mm, vl_i, ldvl, vl_r, mm+2 );
    }
    if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
        LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, mm, vr_i, ldvr, vr_r, mm+2 );
    }
    info_i = LAPACKE_zhsein_work( LAPACK_ROW_MAJOR, job_i, eigsrc_i, initv_i,
                                  select_i, n_i, h_r, ldh_r, w_i, vl_r, ldvl_r,
                                  vr_r, ldvr_r, mm_i, &m_i, work_i, rwork_i,
                                  ifaill_i, ifailr_i );

    if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
        LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, mm, vl_r, mm+2, vl_i, ldvl );
    }
    if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
        LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, mm, vr_r, mm+2, vr_i, ldvr );
    }

    failed = compare_zhsein( w, w_i, vl, vl_i, vr, vr_i, m, m_i, ifaill,
                             ifaill_i, ifailr, ifailr_i, info, info_i, job,
                             ldvl, ldvr, mm, n );
    if( failed == 0 ) {
        printf( "PASSED: row-major middle-level interface to zhsein\n" );
    } else {
        printf( "FAILED: row-major middle-level interface to zhsein\n" );
    }

    /* Initialize input data, call the row-major high-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < n; i++ ) {
        select_i[i] = select[i];
    }
    for( i = 0; i < ldh*n; i++ ) {
        h_i[i] = h[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < ldvl*mm; i++ ) {
        vl_i[i] = vl_save[i];
    }
    for( i = 0; i < ldvr*mm; i++ ) {
        vr_i[i] = vr_save[i];
    }
    for( i = 0; i < n*n; i++ ) {
        work_i[i] = work[i];
    }
    for( i = 0; i < n; i++ ) {
        rwork_i[i] = rwork[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifaill_i[i] = ifaill_save[i];
    }
    for( i = 0; i < mm; i++ ) {
        ifailr_i[i] = ifailr_save[i];
    }

    /* Init row_major arrays */
    LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, h_i, ldh, h_r, n+2 );
    if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
        LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, mm, vl_i, ldvl, vl_r, mm+2 );
    }
    if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
        LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, mm, vr_i, ldvr, vr_r, mm+2 );
    }
    info_i = LAPACKE_zhsein( LAPACK_ROW_MAJOR, job_i, eigsrc_i, initv_i,
                             select_i, n_i, h_r, ldh_r, w_i, vl_r, ldvl_r, vr_r,
                             ldvr_r, mm_i, &m_i, ifaill_i, ifailr_i );

    if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
        LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, mm, vl_r, mm+2, vl_i, ldvl );
    }
    if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
        LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, mm, vr_r, mm+2, vr_i, ldvr );
    }

    failed = compare_zhsein( w, w_i, vl, vl_i, vr, vr_i, m, m_i, ifaill,
                             ifaill_i, ifailr, ifailr_i, info, info_i, job,
                             ldvl, ldvr, mm, n );
    if( failed == 0 ) {
        printf( "PASSED: row-major high-level interface to zhsein\n" );
    } else {
        printf( "FAILED: row-major high-level interface to zhsein\n" );
    }

    /* Release memory */
    if( select != NULL ) {
        LAPACKE_free( select );
    }
    if( select_i != NULL ) {
        LAPACKE_free( select_i );
    }
    if( h != NULL ) {
        LAPACKE_free( h );
    }
    if( h_i != NULL ) {
        LAPACKE_free( h_i );
    }
    if( h_r != NULL ) {
        LAPACKE_free( h_r );
    }
    if( w != NULL ) {
        LAPACKE_free( w );
    }
    if( w_i != NULL ) {
        LAPACKE_free( w_i );
    }
    if( w_save != NULL ) {
        LAPACKE_free( w_save );
    }
    if( vl != NULL ) {
        LAPACKE_free( vl );
    }
    if( vl_i != NULL ) {
        LAPACKE_free( vl_i );
    }
    if( vl_r != NULL ) {
        LAPACKE_free( vl_r );
    }
    if( vl_save != NULL ) {
        LAPACKE_free( vl_save );
    }
    if( vr != NULL ) {
        LAPACKE_free( vr );
    }
    if( vr_i != NULL ) {
        LAPACKE_free( vr_i );
    }
    if( vr_r != NULL ) {
        LAPACKE_free( vr_r );
    }
    if( vr_save != NULL ) {
        LAPACKE_free( vr_save );
    }
    if( work != NULL ) {
        LAPACKE_free( work );
    }
    if( work_i != NULL ) {
        LAPACKE_free( work_i );
    }
    if( rwork != NULL ) {
        LAPACKE_free( rwork );
    }
    if( rwork_i != NULL ) {
        LAPACKE_free( rwork_i );
    }
    if( ifaill != NULL ) {
        LAPACKE_free( ifaill );
    }
    if( ifaill_i != NULL ) {
        LAPACKE_free( ifaill_i );
    }
    if( ifaill_save != NULL ) {
        LAPACKE_free( ifaill_save );
    }
    if( ifailr != NULL ) {
        LAPACKE_free( ifailr );
    }
    if( ifailr_i != NULL ) {
        LAPACKE_free( ifailr_i );
    }
    if( ifailr_save != NULL ) {
        LAPACKE_free( ifailr_save );
    }

    return 0;
}
Example #6
0
int main(void)
{
    /* Local scalars */
    char range, range_i;
    char order, order_i;
    lapack_int n, n_i;
    double vl, vl_i;
    double vu, vu_i;
    lapack_int il, il_i;
    lapack_int iu, iu_i;
    double abstol, abstol_i;
    lapack_int m, m_i;
    lapack_int nsplit, nsplit_i;
    lapack_int info, info_i;
    lapack_int i;
    int failed;

    /* Local arrays */
    double *d = NULL, *d_i = NULL;
    double *e = NULL, *e_i = NULL;
    double *w = NULL, *w_i = NULL;
    lapack_int *iblock = NULL, *iblock_i = NULL;
    lapack_int *isplit = NULL, *isplit_i = NULL;
    double *work = NULL, *work_i = NULL;
    lapack_int *iwork = NULL, *iwork_i = NULL;
    double *w_save = NULL;
    lapack_int *iblock_save = NULL;
    lapack_int *isplit_save = NULL;

    /* Iniitialize the scalar parameters */
    init_scalars_dstebz( &range, &order, &n, &vl, &vu, &il, &iu, &abstol );
    range_i = range;
    order_i = order;
    n_i = n;
    vl_i = vl;
    vu_i = vu;
    il_i = il;
    iu_i = iu;
    abstol_i = abstol;

    /* Allocate memory for the LAPACK routine arrays */
    d = (double *)LAPACKE_malloc( n * sizeof(double) );
    e = (double *)LAPACKE_malloc( (n-1) * sizeof(double) );
    w = (double *)LAPACKE_malloc( n * sizeof(double) );
    iblock = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
    isplit = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
    work = (double *)LAPACKE_malloc( 4*n * sizeof(double) );
    iwork = (lapack_int *)LAPACKE_malloc( 3*n * sizeof(lapack_int) );

    /* Allocate memory for the C interface function arrays */
    d_i = (double *)LAPACKE_malloc( n * sizeof(double) );
    e_i = (double *)LAPACKE_malloc( (n-1) * sizeof(double) );
    w_i = (double *)LAPACKE_malloc( n * sizeof(double) );
    iblock_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
    isplit_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
    work_i = (double *)LAPACKE_malloc( 4*n * sizeof(double) );
    iwork_i = (lapack_int *)LAPACKE_malloc( 3*n * sizeof(lapack_int) );

    /* Allocate memory for the backup arrays */
    w_save = (double *)LAPACKE_malloc( n * sizeof(double) );
    iblock_save = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
    isplit_save = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );

    /* Allocate memory for the row-major arrays */

    /* Initialize input arrays */
    init_d( n, d );
    init_e( (n-1), e );
    init_w( n, w );
    init_iblock( n, iblock );
    init_isplit( n, isplit );
    init_work( 4*n, work );
    init_iwork( 3*n, iwork );

    /* Backup the ouptut arrays */
    for( i = 0; i < n; i++ ) {
        w_save[i] = w[i];
    }
    for( i = 0; i < n; i++ ) {
        iblock_save[i] = iblock[i];
    }
    for( i = 0; i < n; i++ ) {
        isplit_save[i] = isplit[i];
    }

    /* Call the LAPACK routine */
    dstebz_( &range, &order, &n, &vl, &vu, &il, &iu, &abstol, d, e, &m, &nsplit,
             w, iblock, isplit, work, iwork, &info );

    /* Initialize input data, call the column-major middle-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < n; i++ ) {
        d_i[i] = d[i];
    }
    for( i = 0; i < (n-1); i++ ) {
        e_i[i] = e[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < n; i++ ) {
        iblock_i[i] = iblock_save[i];
    }
    for( i = 0; i < n; i++ ) {
        isplit_i[i] = isplit_save[i];
    }
    for( i = 0; i < 4*n; i++ ) {
        work_i[i] = work[i];
    }
    for( i = 0; i < 3*n; i++ ) {
        iwork_i[i] = iwork[i];
    }
    info_i = LAPACKE_dstebz_work( range_i, order_i, n_i, vl_i, vu_i, il_i, iu_i,
                                  abstol_i, d_i, e_i, &m_i, &nsplit_i, w_i,
                                  iblock_i, isplit_i, work_i, iwork_i );

    failed = compare_dstebz( m, m_i, nsplit, nsplit_i, w, w_i, iblock, iblock_i,
                             isplit, isplit_i, info, info_i, n );
    if( failed == 0 ) {
        printf( "PASSED: column-major middle-level interface to dstebz\n" );
    } else {
        printf( "FAILED: column-major middle-level interface to dstebz\n" );
    }

    /* Initialize input data, call the column-major high-level
     * interface to LAPACK routine and check the results */
    for( i = 0; i < n; i++ ) {
        d_i[i] = d[i];
    }
    for( i = 0; i < (n-1); i++ ) {
        e_i[i] = e[i];
    }
    for( i = 0; i < n; i++ ) {
        w_i[i] = w_save[i];
    }
    for( i = 0; i < n; i++ ) {
        iblock_i[i] = iblock_save[i];
    }
    for( i = 0; i < n; i++ ) {
        isplit_i[i] = isplit_save[i];
    }
    for( i = 0; i < 4*n; i++ ) {
        work_i[i] = work[i];
    }
    for( i = 0; i < 3*n; i++ ) {
        iwork_i[i] = iwork[i];
    }
    info_i = LAPACKE_dstebz( range_i, order_i, n_i, vl_i, vu_i, il_i, iu_i,
                             abstol_i, d_i, e_i, &m_i, &nsplit_i, w_i, iblock_i,
                             isplit_i );

    failed = compare_dstebz( m, m_i, nsplit, nsplit_i, w, w_i, iblock, iblock_i,
                             isplit, isplit_i, info, info_i, n );
    if( failed == 0 ) {
        printf( "PASSED: column-major high-level interface to dstebz\n" );
    } else {
        printf( "FAILED: column-major high-level interface to dstebz\n" );
    }

    failed = compare_dstebz( m, m_i, nsplit, nsplit_i, w, w_i, iblock, iblock_i,
                             isplit, isplit_i, info, info_i, n );
    if( failed == 0 ) {
        printf( "PASSED: row-major middle-level interface to dstebz\n" );
    } else {
        printf( "FAILED: row-major middle-level interface to dstebz\n" );
    }

    failed = compare_dstebz( m, m_i, nsplit, nsplit_i, w, w_i, iblock, iblock_i,
                             isplit, isplit_i, info, info_i, n );
    if( failed == 0 ) {
        printf( "PASSED: row-major high-level interface to dstebz\n" );
    } else {
        printf( "FAILED: row-major high-level interface to dstebz\n" );
    }

    /* Release memory */
    if( d != NULL ) {
        LAPACKE_free( d );
    }
    if( d_i != NULL ) {
        LAPACKE_free( d_i );
    }
    if( e != NULL ) {
        LAPACKE_free( e );
    }
    if( e_i != NULL ) {
        LAPACKE_free( e_i );
    }
    if( w != NULL ) {
        LAPACKE_free( w );
    }
    if( w_i != NULL ) {
        LAPACKE_free( w_i );
    }
    if( w_save != NULL ) {
        LAPACKE_free( w_save );
    }
    if( iblock != NULL ) {
        LAPACKE_free( iblock );
    }
    if( iblock_i != NULL ) {
        LAPACKE_free( iblock_i );
    }
    if( iblock_save != NULL ) {
        LAPACKE_free( iblock_save );
    }
    if( isplit != NULL ) {
        LAPACKE_free( isplit );
    }
    if( isplit_i != NULL ) {
        LAPACKE_free( isplit_i );
    }
    if( isplit_save != NULL ) {
        LAPACKE_free( isplit_save );
    }
    if( work != NULL ) {
        LAPACKE_free( work );
    }
    if( work_i != NULL ) {
        LAPACKE_free( work_i );
    }
    if( iwork != NULL ) {
        LAPACKE_free( iwork );
    }
    if( iwork_i != NULL ) {
        LAPACKE_free( iwork_i );
    }

    return 0;
}
int main (int argc, char const *argv[])
{
	int i,j;
	int dir = 1; /* 0: N, 1: E, 2: S, 3: W */ 
	char s[200];

	/* debug("Starting Application: %s\n", argv[0]); */
	
	if(argc != 2)
	{
		fprintf(stderr,"Use: %s program\n", argv[0]);
		return EXIT_FAILURE;
	}
	runWish();
	
	close(STDIN_FILENO);
	if(open(argv[1],O_RDONLY,NULL))
	{
		printf("Error al Abrir el archivo\n");
		return EXIT_FAILURE;
	}

	srand(time(NULL));

	for(i=0;i<MAXX/GORDO;i++)
		for(j=0;j<MAXY/GORDO;j++)
			tablero[i][j] = 0;
	
	init_w(MAXX, MAXY,"Gusano - Tarea 3");

	g = init_g(MAXX/2, MAXY/2, dir, 4); /* x,y,dir,largo */
	if(!galleta_id) cookie(MAXX, MAXY);
	
	for(;;)
	{
		usleep(100000);

		dir = eval(g);
		if(dir == -1)
		{
			exit(EXIT_FAILURE);
		} 
		else
		{
			g->dir = dir;

			if( !move_g(g) )
			{
				sprintf(s, "Boing!!, score = %d", size_l(g->cuerpo));
				showColitionPoint(g);
				free_g(g);
				g=NULL;
				close_w(s, 100, 100);
				waitWish(wpid);
				exit(0);
			}
		}
		
		close(STDIN_FILENO);
		
		if(open(argv[1],O_RDONLY,NULL))
		{
			printf("Error al Abrir el archivo\n");
			exit(EXIT_FAILURE);
		}
	}

	exit(EXIT_FAILURE);
}
Example #8
0
//average SGD implemented by Julius 2014.08.27
void LLC_SGD(double *w, double *x, double *centers, int *knn_idx, int knn, int d) {
    int i, j, iter=0, iter0=-1;
    float GAMMA = 2, adaGAMMA=GAMMA;
    memset(w, 0.01, knn*sizeof(double));
    
    //minimizing 0.5*||x - w*centers||2,2 + 0.5*lambda*||w||2,2
    srand(time(NULL));
    float past_grad[64] = {0};

    //w[0] = w[1] = 0.25;
    
    init_w(w, knn);
    eval_obj_iter = 0;
    while(iter < knn*30) {
        for(i=0; i<BATCH_SIZE; i++)
            batch_idx[i] = rand()%d;    //[0, 127]
        
        adaGAMMA = GAMMA*pow(1+GAMMA*BETA_SGD*(iter0+1), -0.75);
        //adaGAMMA = GAMMA;
        if(iter > knn*8)
            iter0++;
        //if(iter0 == 0)
        //    printf("============Start averaging!!============\n");
        
        //printf("adaGAMMA[%d]: %f\n", iter, adaGAMMA);
        
        float wcenters[BATCH_SIZE]={0}, sub_grad=0;
        
        //mini-batch SGD, if BATCH_SIZE = 1, then it is shrunk to SGD
        
        if(BATCH_SIZE > 1) {    //mini-batch SGD
            for(j=0; j<BATCH_SIZE; j++) {
                int idx = batch_idx[j];
                for(i=0; i<knn; i++)
                    wcenters[j] += w[i]*centers[knn_idx[i]*d+idx];
                wcenters[j] = x[idx] - wcenters[j];
            }
            
            for(i=0; i<knn; i++) {
                sub_grad=0;
                for(j=0; j<BATCH_SIZE; j++) {
                    int idx = batch_idx[j];
                    sub_grad += wcenters[j]*centers[knn_idx[i]*d+idx];
                }
                
                sub_grad /= BATCH_SIZE; //average over mini-batch gradients
                
                sub_grad += BETA_SGD*w[i];
                sub_grad *= adaGAMMA;
                
                if(abs_float(sub_grad) < 5e-4)  //neglect too small update
                    continue;
                
                w[i] += (sub_grad);
                
                w[i] = (w[i] > 1) ? 1: w[i];
                w[i] = (w[i] < -1) ? -1: w[i];
            }
        }
        else {  //SGD
            int idx = batch_idx[0];
            for(i=0; i<knn; i++)
                wcenters[0] += w[i]*centers[knn_idx[i]*d+idx];
            for(i=0; i<knn; i++) {
                sub_grad = (x[idx] - wcenters[0])*centers[knn_idx[i]*d+idx];    //calculate sub_grad[0~127]
                sub_grad += BETA_SGD*w[i];
                sub_grad *= adaGAMMA;
                
                if(abs_float(sub_grad) < 5e-4)  //neglect too small update
                    continue;
                
                double lower_bound, upper_bound;
                double tentaive_w = w[i] + sub_grad;
                if(w[i] > 0) {
                    lower_bound = 0;  //avg_w - 2*avg < x < avg_w + 2*avg
                    upper_bound = 2*w[i];
                }
                else {
                    lower_bound = 2*w[i];
                    upper_bound = 0;
                }
                
                w[i] += (sub_grad);
                
                w[i] = (tentaive_w > upper_bound) ? upper_bound: tentaive_w;
                w[i] = (tentaive_w < lower_bound) ? lower_bound: tentaive_w;
                
                w[i] = (w[i] > 1) ? 1: w[i];
                w[i] = (w[i] < -1) ? -1: w[i];
            }
        }
        
        if(iter0 == 0) {
            for(i=0; i<knn; i++)
                avg_w[i] = w[i];
        }
        if(iter0 >= 0) {
            for(i=0; i<knn; i++) {
                double past_w = avg_w[i];
                avg_w[i] = w[i] + (double)iter0/(iter0+1)*(avg_w[i]-w[i]);
                past_grad[i] = avg_w[i] - past_w;
                
                double tentaive_w = avg_w[i] + 2*past_grad[i];  //momentum is used
                
                double lower_bound, upper_bound;
                if(avg_w[i] > 0) {
                    lower_bound = -2*avg_w[i];  //avg_w - 3*avg < x < avg_w + 3*avg
                    upper_bound = 4*avg_w[i];
                }
                else {
                    lower_bound = 4*avg_w[i];
                    upper_bound = -2*avg_w[i];
                }
                avg_w[i] = (tentaive_w > upper_bound) ? upper_bound: tentaive_w;
                avg_w[i] = (tentaive_w < lower_bound) ? lower_bound: tentaive_w;
                
                avg_w[i] = (avg_w[i] > 1) ? 1: avg_w[i];
                avg_w[i] = (avg_w[i] < -1) ? -1: avg_w[i];
                
                //printf("[%d](w, grad) = (%f, %f)\n", i, avg_w[i], past_grad[i]);
            }
#ifdef SGD_DEBUGGING
            eval_obj(avg_w, x, centers, knn_idx, knn, d);
#endif
        }
        //norm_w(w, d);
        else {
#ifdef SGD_DEBUGGING
            eval_obj(w, x, centers, knn_idx, knn, d);
#endif
        }
        
        iter++;
    }
    double sum=0;
    for(i=0; i<knn; i++)
        sum += avg_w[i];
    
    for(i=0; i<knn; i++) {
        avg_w[i] /= sum;
        if(abs_double(avg_w[i]) < TOLERANCE)    //cut-off small values
            avg_w[i] = 0;
    }
    
#ifdef SGD_DEBUGGING
    printf("LLC_SGD w: (");
    for(i=0; i<knn; i++)
        printf("%f ", avg_w[i]);
    printf(")\n");
#endif
}
Example #9
0
/* block is the 512-bit/64-byte/16-word input block.
 * hash is the 160-bit/20-byte/5-word input and output hash
 * native_in is 1 if we don't have to revert the bytes of the block on
 * a little-endian machine */
static void compute_sha512 (const uint64_t * block,
                            uint512 * hash, int native_in) 
{
  uint64_t W [80];
  int t;

  /* step 1 */
#if __BYTE_ORDER == __LITTLE_ENDIAN
  if (native_in)
#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
    init_w_native_byte_order (W, block);
#if __BYTE_ORDER == __LITTLE_ENDIAN
  else
    init_w (W, block);
#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */

  /* step 2 */
  uint64_t a = hash->i [0];
  uint64_t b = hash->i [1];
  uint64_t c = hash->i [2];
  uint64_t d = hash->i [3];
  uint64_t e = hash->i [4];
  uint64_t f = hash->i [5];
  uint64_t g = hash->i [6];
  uint64_t h = hash->i [7];
#ifdef DEBUG_PRINT
  if (debugging)
    printf ("in: %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n",
            a, b, c, d, e, f, g, h);

  if (debugging)
    printf ("          A                B                C                D                E                F                G                H\n");
#endif /* DEBUG_PRINT */
  /* step 3 */
  for (t = 0; t < 80; t++) {
    uint64_t t1 =
      h + SIGMA1 (e) + ch (e, f, g) + K512 [t] + W [t];
    uint64_t t2 = SIGMA0 (a) + maj (a, b, c);
    h = g;
    g = f;
    f = e;
    e = d + t1;
    d = c;
    c = b;
    b = a;
    a = t1 + t2;
#ifdef DEBUG_PRINT
    if (debugging)
      printf ("t = %2d: %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n",
              t, a, b, c, d, e, f, g, h);
#endif /* DEBUG_PRINT */
  }

  /* step 4 */
  hash->i [0] += a;
  hash->i [1] += b;
  hash->i [2] += c;
  hash->i [3] += d;
  hash->i [4] += e;
  hash->i [5] += f;
  hash->i [6] += g;
  hash->i [7] += h;
  if (debugging)
    printf ("hash = %16" PRIx64 " %16" PRIx64 " %16" PRIx64 " %16" PRIx64 " %16" PRIx64 " %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n",
            hash->i [0], hash->i [1], hash->i [2], hash->i [3],
            hash->i [4], hash->i [5], hash->i [6], hash->i [7]);
}