00001 #include <stdlib.h>
00002 #include "nl.h"
00003
00004
00005
00006
00007
00008 int main()
00009 {
00010 double *x, *y;
00011 size_t n, *k, nk, j;
00012 conv_point *p;
00013
00014 n = 10;
00015
00016 x = nl_dvector_create(n);
00017 y = nl_dvector_create(n);
00018 k = nl_xvector_create(n);
00019 p = (conv_point*)malloc(n * sizeof(conv_point));
00020
00021 x[0] = 0.9501; y[0] = 0.6154;
00022 x[1] = 0.2311; y[1] = 0.7919;
00023 x[2] = 0.6068; y[2] = 0.9218;
00024 x[3] = 0.4860; y[3] = 0.7382;
00025 x[4] = 0.8913; y[4] = 0.1763;
00026 x[5] = 0.7621; y[5] = 0.4057;
00027 x[6] = 0.4565; y[6] = 0.9355;
00028 x[7] = 0.0185; y[7] = 0.9169;
00029 x[8] = 0.8214; y[8] = 0.4103;
00030 x[9] = 0.4447; y[9] = 0.8936;
00031
00032 conv_andrew(x, y, n, p, &nk);
00033
00034 printf("Заданные точки:\n");
00035 for (j = 0; j < n; j++)
00036 printf(" %f %f \n", x[j], y[j]);
00037
00038 printf("\nВершины выпуклой оболочки:\n");
00039 for (j = 0; j < nk; j++)
00040 printf(" %d: %f %f \n", p[j].k, p[j].x, p[j].y);
00041
00042 nl_dvector_free(x);
00043 nl_dvector_free(y);
00044 nl_xvector_free(k);
00045 free(p);
00046
00047 return 0;
00048 }