Exemplo n.º 1
0
int make_matrix(int v)
{
	++mark_v;
	int row = 0, cell = 0;
	for(int i = v; i <= n; i *= 2, ++row)
	{
		int c = 0;
		for(int j = i; j <= n; j *= 3, ++c)
		{
			mark[j] = 1;
			data[row][c] = mark_v;
		}

		cell = std::max(cell, c);
	}

	return solve_matrix(row, cell);
}
Exemplo n.º 2
0
uint32_t  decode(uint32_t *x, uint32_t *shares, int n, int k)
{

    if(n < k)
    {
        return -1;
    }

    uint32_t **eqn;
    uint32_t *eqn_all;

    eqn = malloc(sizeof(*eqn) * k);
    eqn_all = malloc(sizeof(*eqn_all) * k *(k + 1));

    int a;
    for(a = 0; a < k; a++)
    {
        eqn[a] = eqn_all + ((k + 1) * a);
    }

    int b;
    for(b = 0; b < k; b++)
    {

        uint32_t xp = 1;
        uint32_t xr = x[b];

        for(a = 0; a < k; a++)
        {
            eqn[b][a] = xp;
            xp = multiply(xp, xr);
        }
        eqn[b][k] = shares[b];
    }

    solve_matrix(eqn, k);

    return linear_solve(eqn[0][0], eqn[0][k]);

}
Exemplo n.º 3
0
/* main program code */
int main(int argc, char** argv) {
    /* Verify input arguments */
    
    if(argc!=4)   show_help();
    
    load_file(argv[3]);
    f=atoi(argv[1]);
    Dt=atof(argv[2]);
    printf("Frequency: %d\n",f);
    printf("Delta Time: %f\n",Dt);
    printf("Number of samples: %d\n",n);
    /* create matrices */
    C = (double*)malloc(sizeof(double)*n*n);
    SF = (double*)malloc(sizeof(double)*n);
    CV = (double*)malloc(sizeof(double)*n);
    
    
    create_coefficient_matrix();
    solve_matrix();
    compute_frequencies();
    compute_approximation();
    compute_dm();
    output_data();
}