File: linear.c

package info (click to toggle)
fitsh 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 2,768 kB
  • ctags: 4,050
  • sloc: ansic: 53,352; makefile: 1,120; sh: 25
file content (49 lines) | stat: -rw-r--r-- 1,500 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*****************************************************************************/
/* linear.c								     */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Demonstartion and/or test module for `lfit` dynamic extensions.	     */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* (c) 2008; Pal, A. (apal@szofi.elte.hu)				     */
/*****************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#include <lfit/lfit.h>

/*****************************************************************************/

/* these functions can be declared as static ones since the wrapper inside
 `lfit` reads only the exported `lfitfunction` arrays (here: "linear") */
static int function_line(double *vars,double *idvs,double *ret,double *diff);

lfitfunction linear [] =
 {	{ "line", LFITFUNCTION_LINEAR,	2, 1, function_line },
	{ NULL, 0, 0, 0, NULL }
 };

/*****************************************************************************/

static int function_line(double *vars,double *idvs,double *ret,double *diff)
{

 *ret = vars[0]*idvs[0]+vars[1];
 if ( diff != NULL )
  {	diff[0]=idvs[0];
	diff[1]=1.0;
  }
/*
 *ret = vars[0]*vars[2]+vars[1];
 if ( diff != NULL )
  {	diff[0]=vars[2];
	diff[1]=1.0;
	diff[2]=vars[0];
  }
*/
 return(0);
}

/*****************************************************************************/