1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
/*
ras - Redundant Archive System
Copyright (C) 1999 Nick Cleaton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Nick Cleaton <nick@cleaton.net>
*/
/*
field.h
Polynomial interpolation over the finite field GF(256).
*/
typedef unsigned char field_t;
/* the type over which finite field arithmetic will be performed */
void init_field();
/* Call once at the start, sets up lookup tables and so on.
*/
void free_field();
/* Call at the end, frees resources allocated by init_field.
*/
field_t *Makevector(size_t segcount, int *gotpoints, int wantpoint);
/* The set of "segcount" ints pointed to by "gotpoints" and the int
"wantpoint" must all be distinct and in the range 0 to 255.
"segcount" x,y pairs for distinct x define a polynomial of order
"segcount"-1. Makevector returns a vector of "segcount" field_ts
which (when dot-producted with a vector of "segcount" y values)
has the effect of evaluating this polynomial at the x value
"wantpoint".
*/
void dotproduct(size_t segcount, uchar *inbufbase, size_t inbufoffset,
uchar *outbuf, field_t *vector, size_t bytes);
/* Reads "bytes" bytes of data from each of "segcount" input buffers, and
writes "bytes" bytes of data out to "outbuf". The ith byte is computed
as the dot product of "vector" and the vector of the ith bytes of all
the input buffers. The first input buffer starts at "inbufbase", the
second starts at "inbufbase" + "inbufoffset", and so on.
*/
|