From f3e144bc8dee4bcc60ff8dc1607bbd88a01d728a Mon Sep 17 00:00:00 2001 From: pnenzi Date: Tue, 23 Aug 2005 18:29:53 +0000 Subject: [PATCH] Changed according to code supplied by Hitoshi Tanaka. --- src/xspice/icm/analog/s_xfer/cfunc.mod | 62 +++++++++++++++++++------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/src/xspice/icm/analog/s_xfer/cfunc.mod b/src/xspice/icm/analog/s_xfer/cfunc.mod index 05e3856de..c8653e580 100644 --- a/src/xspice/icm/analog/s_xfer/cfunc.mod +++ b/src/xspice/icm/analog/s_xfer/cfunc.mod @@ -215,7 +215,7 @@ void cm_s_xfer(ARGS) /* structure holding parms, inputs, outputs, etc. */ denonminator coefficients */ double **num_coefficient; /* dynamic array that holds the numerator coefficients */ - /*double **old_num_coefficient;?* dynamic array that holds the old numerator + double **old_num_coefficient;/* dynamic array that holds the old numerator coefficients */ double factor; /* gain factor in case the highest denominator coefficient is not 1 */ @@ -292,22 +292,23 @@ void cm_s_xfer(ARGS) /* structure holding parms, inputs, outputs, etc. */ /* Allocate storage for coefficient values */ - den_coefficient = (double **) calloc(den_size,sizeof(double)); + den_coefficient = (double **) calloc(den_size,sizeof(double *)); + old_den_coefficient = (double **) calloc(den_size,sizeof(double *)); + + num_coefficient = (double **) calloc(num_size,sizeof(double *)); + old_num_coefficient = (double **) calloc(num_size,sizeof(double *)); for(i=den_size;i<(2*den_size);i++){ - den_coefficient[i-den_size] = cm_analog_alloc(i,sizeof(double)); + old_den_coefficient[i-den_size] = den_coefficient[i-den_size] = + cm_analog_alloc(i,sizeof(double)); } - num_coefficient = (double **) calloc(num_size,sizeof(double)); for(i=2*den_size;i<(2*den_size + num_size);i++){ - num_coefficient[i-2*den_size] = cm_analog_alloc(i,sizeof(double)); + old_num_coefficient[i-2*den_size] = num_coefficient[i-2*den_size] = + cm_analog_alloc(i,sizeof(double)); } -/* I don't really need to allocate old_den_coefficient. It's just that - I free it at the end of the model every time through */ - - old_den_coefficient = (double **) calloc(den_size,sizeof(double)); out = cm_analog_alloc(2*den_size+num_size,sizeof(double)); in = cm_analog_alloc(2*den_size+num_size+1,sizeof(double)); @@ -320,6 +321,27 @@ void cm_s_xfer(ARGS) /* structure holding parms, inputs, outputs, etc. */ ITP_VAR(total_gain) = gain; ITP_VAR_SIZE(total_gain) = 1.0; */ + // Retrieve pointers + + for (i=0; i