Re: [ng-spice] Kernel


To ng-spice@ieee.ing.uniroma1.it
From Arno <A.W.Peters@ieee.org>
Date Fri, 22 Oct 1999 21:39:30 +0200
Delivered-To mailing list ng-spice@ieee.ing.uniroma1.it
In-Reply-To <Pine.LNX.3.96.991022154739.373B-100000@ieee.ing.uniroma1.it >; from pnenzi@ieee.ing.uniroma1.it on Fri, Oct 22, 1999 at 04:06:02PM +0200
Mailing-List contact ng-spice-help@ieee.ing.uniroma1.it; run by ezmlm
References <19991022094329.A32227@cgmd95104.chello.nl > <Pine.LNX.3.96.991022154739.373B-100000@ieee.ing.uniroma1.it >
Reply-To ng-spice@ieee.ing.uniroma1.it
User-Agent Mutt/1.0pre4i

On Fri, Oct 22, 1999 at 04:06:02PM +0200, Paolo Nenzi wrote:
>
> 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};

Let's see if I understand this correctly.  The samples get interpreted
through an intermediary function.  Let x be the stored sample value
and y be the actual value to be used in calculations and the like.
Then the different scales relate to x and y in the following fashion:

  LIN:    y = x
  DEC:    y = 10^x
  OCT:    y = 2^x

DEC and OCT are both power functions only with different bases.  Well,
you can exploit arithmetic relations for some common operations
(exponentiation becomes multiplication, multiplication becomes
addition).  However, a major drawback is to make the code explicitly
handle all these bases/functions.  Especially arithmetic on two
samples with different bases requires some normalization.  Please,
Keep It Stupid Simple.

You may request a certain scale when generating the independent
samples.  I propose the generic function prototype:

  struct sample *sample_xxx_range(sample_t min,
                                  sample_t max,
                                  sample_t steps)
  

  x = sample_linear_range(0, 1e5, 100);
  sample_set_unit(x, frequency_unit);

  y = sample_decadic_range(1, 1e5, 100);
  sample_set_unit(y, frequency_unit);

  z = sample_octave_range(1, 1e5, 100);
  sample_set_unit(z, frequency_unit);


Sample data requires no extra manipulation; simpler support routines.
You still get the ranges you asked for.  I hope you get the idea.

Partial thread listing: