Re: [ng-spice] Kernel


To ng-spice@ieee.ing.uniroma1.it
From Paolo Nenzi <pnenzi@ieee.ing.uniroma1.it>
Date Fri, 22 Oct 1999 16:06:02 +0200 (CEST)
Delivered-To mailing list ng-spice@ieee.ing.uniroma1.it
In-Reply-To <19991022094329.A32227@cgmd95104.chello.nl >
Mailing-List contact ng-spice-help@ieee.ing.uniroma1.it; run by ezmlm
Reply-To ng-spice@ieee.ing.uniroma1.it



On Fri, 22 Oct 1999, Arno wrote:

> > Good, but how to take into account for complex data ???
> Multiple independent variables.  See below.
OK, right!
> 
> > We may modify:
> > 
>     enum data_t { REAL, COMPLEX };   /* Type of data */
YES!
As you can see, in spice there is a distinction between linear scale, log
scale, etc. These distinctions can be included in the data_t field:

1) enum data_t {REAL, COMPLEX, LINEAR, DECADIC, OCT..};
   but seems not very good and consistent

2) add another enum only for the independent variable:
   enum scale_t {LIN,DEC,OCT};


Putting all together:

enum data_t {REAL, COMPLEX};           /* Variable data type */
enum scale_t {LIN,DEC,OCT};            /* Scale of a variable */
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}; 
char frequency_unit[SI_UNITS] = {-1, 0, 0, 0};


struct sample {
    int size;                   /* length of the sample */
    char *units;                /* physical measurement units */
    enum data_t data_type;      /* type of data */
    sample_t *data;             /* has size SIZE */
};
 
struct measurement {
    int count;                  /* number of dependent variables */
    enum scale_t scale_type;    /* Scale used for indip variable */
    struct sample *indep;       /* independent variables (complex) */
    struct sample *data;        /* dependent variables */
};

> To make a linked list of sample, simply add `struct sample *next' to
> the `struct sample'.  Both approaches can be abstracted behind a
> general sample manipulation API.  Simulation code should not be able
> to directly manipulate sample or measurement objects directly.
Using linked lists there is a 4 bytes overhead for each samples, but
shoud be easier to add elements to existing vectors, but do we really need
this feature ?

> Exactly my idea.  It has already been taken into account: char is a
> signed datatype.  I don't expect dimensions of units to go higher than
> 128 or lower than -127 if sizeof(char) == 1.
OK, but I am sticked to the idea that a character is a character and an
integer is an integer. Yes a char is definitively less memory-consuming
than a 4 bytes int.

Paolo


Partial thread listing: