ngspice/src/frontend/interp.c

49 lines
1.1 KiB
C
Raw Normal View History

2000-04-27 22:03:57 +02:00
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
2000-04-27 22:03:57 +02:00
**********/
/*
* Polynomial interpolation code.
*/
#include "ngspice/ngspice.h"
#include "ngspice/cpdefs.h"
#include "ngspice/ftedefs.h"
#include "ngspice/dvec.h"
2000-04-27 22:03:57 +02:00
#include "interp.h"
void
lincopy(struct dvec *ov, double *newscale, int newlen, struct dvec *oldscale)
{
struct dvec *v;
double *nd;
if (!isreal(ov)) {
fprintf(cp_err, "Warning: %s is not real\n", ov->v_name);
return;
}
2000-04-27 22:03:57 +02:00
if (ov->v_length < oldscale->v_length) {
fprintf(cp_err, "Warning: %s is too short\n", ov->v_name);
return;
}
v = dvec_alloc(copy(ov->v_name),
ov->v_type,
ov->v_flags | VF_PERMANENT,
newlen, NULL);
2000-04-27 22:03:57 +02:00
2015-12-28 20:24:11 +01:00
nd = v->v_realdata;
2000-04-27 22:03:57 +02:00
if (!ft_interpolate(ov->v_realdata, nd, oldscale->v_realdata,
oldscale->v_length, newscale, newlen, 1))
{
2000-04-27 22:03:57 +02:00
fprintf(cp_err, "Error: can't interpolate %s\n", ov->v_name);
return;
}
2000-04-27 22:03:57 +02:00
vec_new(v);
}