Re: [ng-spice] Kernel
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:
- Re: [ng-spice] Kernel, (continued)
Stephen Tell