Files correlati : Ricompilazione Demo : [ ] Commento : Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll) git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			40 lines
		
	
	
		
			881 B
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			881 B
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| #include <stdio.h>
 | |
| #include "gm.h"
 | |
| void main(void);
 | |
| 
 | |
| void main()
 | |
| {
 | |
| 	DEC	*xarr[100], *yarr[100], *p;
 | |
| 	DECP	lina, linb, corr, gx, gy, px, py;
 | |
| 	int	n, i;
 | |
| 	
 | |
| 	printf("Number of elements:  ");
 | |
| 	scanf("%d", &n);
 | |
| 	AllocateDecimalArray(xarr, n);
 | |
| 	AllocateDecimalArray(yarr, n);
 | |
| 	for (i=0; i<n; i++)  {
 | |
| 		printf("X Element #%d:  ",i);
 | |
| 		dscanf("%t", xarr[i]);
 | |
| 		printf("Y Element #%d:  ",i);
 | |
| 		dscanf("%t", yarr[i]);
 | |
| 	}
 | |
| 	
 | |
| 	p = LinearEstimate(corr, lina, linb, xarr, yarr, n);
 | |
| 	if (p)  {
 | |
| 		dprintf("\nY = %t + %t * X\n", lina, linb);
 | |
| 		dprintf("Correleation coefficient:  %t\n", corr);
 | |
| 	}
 | |
| 	else
 | |
| 		dprintf("\nLinearEstimate failed\n");
 | |
| 
 | |
| 	printf("\nGiven X value:  ");
 | |
| 	dscanf("%t", gx);
 | |
| 	if (PredictY(py, gx))
 | |
| 		dprintf("X = %t corresponds to Y = %t\n", gx, py);
 | |
| 	
 | |
| 	printf("\nGiven Y value:  ");
 | |
| 	dscanf("%t", gy);
 | |
| 	if (PredictX(px, gy))
 | |
| 		dprintf("Y = %t corresponds to X = %t\n", gy, px);
 | |
| }
 |