File: examples.c

package info (click to toggle)
libwn6 6.0-12
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,004 kB
  • ctags: 3,903
  • sloc: ansic: 45,078; makefile: 958; csh: 274; sh: 26
file content (40 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (4)
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
#include <stdio.h>

#include "wnlib.h"
#include "wnmem.h"

#include "wnvect.h"


#define LEN   10


void main(void)
{
  double *vect1,*vect2,*vect3;

  wn_gpmake("general_free");

  wn_make_vect(&vect1,LEN);
  wn_make_vect(&vect2,LEN);
  wn_make_vect(&vect3,LEN);

  wn_random_vect(vect1,LEN);
  wn_print_vect(vect1,LEN);
  wn_copy_vect(vect2,vect1,LEN);
  wn_print_vect(vect1,LEN);
  wn_random_vect(vect2,LEN);

  printf("v1.v2 = %lf\n",wn_dot_vects(vect1,vect2,LEN));
  printf("v1.v1 = %lf\n",wn_dot_vects(vect1,vect1,LEN));
  printf("norm2(v1) = %lf\n",wn_norm2_vect(vect1,LEN));
  printf("norm(v1) = %lf\n",wn_norm_vect(vect1,LEN));
  printf("corr(v1,v2)) = %lf\n",
	 wn_dot_vects(vect1,vect2,LEN)/
	 (wn_norm_vect(vect1,LEN)*wn_norm_vect(vect2,LEN)));

  wn_free_vect(vect1,LEN);

  wn_gpfree();
}