Re: [ng-spice] Kernel
On Wed, Oct 20, 1999 at 08:59:04AM +0200, Paolo Nenzi wrote:
> Another question: I need to store the points (time, frequency, ...) where
> the analisys was perfomed, how can I store them and how can I realte them
> to the vector ?
IMHO the basic building blocks are samples. Sequences of samples make
up an experiment. What are the basic properties of samples? They
have one independent variable and a number of dependent variables.
They are (mostly) relating one quantity to another. Some examples:
time vs. voltage, freqency vs. current, poles or zeros in the complex
plane, voltage vs. current.
See the following program for some thoughts on this issue.
typedef double sample_t;
enum si_units { SECOND, METER, KILOGRAM, AMPERE, SI_UNITS };
char scalar_unit[SI_UNITS] = {0, 0, 0, 0};
char time_unit[SI_UNITS] = {1, 0, 0, 0};
char distance_unit[SI_UNITS] = {0, 1, 0, 0};
char mass_unit[SI_UNITS] = {0, 0, 1, 0};
char current_unit[SI_UNITS] = {0, 0, 1, 0};
struct sample {
int size; /* length of the sample */
char *units; /* physical measurement units */
sample_t *data; /* has size SIZE */
};
struct measurement {
int count; /* number of dependent variables */
struct sample indep; /* independent variable */
struct sample *data; /* dependent variables */
};
int main(void)
{
struct sample s;
s.size = 3;
s.units = time_unit;
s.data = malloc(s.size * sizeof(sample_t));
s.data[0] = .1;
s.data[1] = .25;
s.data[2] = -4e-3;
return 0;
}
Also note the use of the si_units enum. I indend this to hold the
physical units of the measurement. Add to the mix an API for adding,
removing, mathematically manipulating, sorting samples; this could be
the basis for a nice simulator.
--
Arno
Partial thread listing:
- Re: [ng-spice] Kernel, (continued)