-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgeompack.cpp
4470 lines (4042 loc) · 93.2 KB
/
geompack.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <fstream>
# include <cmath>
# include <ctime>
# include <cstring>
using namespace std;
# include "geompack.hpp"
//****************************************************************************80
void alpha_measure ( int n, double z[], int triangle_order, int triangle_num,
int triangle_node[], double *alpha_min, double *alpha_ave,
double *alpha_area )
//****************************************************************************80
//
// Purpose:
//
// ALPHA_MEASURE determines the triangulated pointset quality measure ALPHA.
//
// Discusion:
//
// The ALPHA measure evaluates the uniformity of the shapes of the triangles
// defined by a triangulated pointset.
//
// We compute the minimum angle among all the triangles in the triangulated
// dataset and divide by the maximum possible value (which, in degrees,
// is 60). The best possible value is 1, and the worst 0. A good
// triangulation should have an ALPHA score close to 1.
//
// The code has been modified to 'allow' 6-node triangulations.
// However, no effort is made to actually process the midside nodes.
// Only information from the vertices is used.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 21 June 2009
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int N, the number of points.
//
// Input, double Z[2*N], the points.
//
// Input, int TRIANGLE_ORDER, the order of the triangles.
//
// Input, int TRIANGLE_NUM, the number of triangles.
//
// Input, int TRIANGLE_NODE(TRIANGLE_ORDER,TRIANGLE_NUM),
// the triangulation.
//
// Output, double *ALPHA_MIN, the minimum value of ALPHA over all
// triangles.
//
// Output, double *ALPHA_AVE, the value of ALPHA averaged over
// all triangles.
//
// Output, double *ALPHA_AREA, the value of ALPHA averaged over
// all triangles and weighted by area.
//
{
double a_angle;
int a_index;
double a_x;
double a_y;
double ab_len;
//double alpha;
double area;
double area_total;
double b_angle;
int b_index;
double b_x;
double b_y;
double bc_len;
double c_angle;
int c_index;
double c_x;
double c_y;
double ca_len;
double pi = 3.141592653589793;
int triangle;
//double value;
*alpha_min = r8_huge ( );
*alpha_ave = 0.0;
*alpha_area = 0.0;
area_total = 0.0;
for ( triangle = 0; triangle < triangle_num; triangle++ )
{
a_index = triangle_node[0+triangle*triangle_order];
b_index = triangle_node[1+triangle*triangle_order];
c_index = triangle_node[2+triangle*triangle_order];
a_x = z[0+(a_index-1)*2];
a_y = z[1+(a_index-1)*2];
b_x = z[0+(b_index-1)*2];
b_y = z[1+(b_index-1)*2];
c_x = z[0+(c_index-1)*2];
c_y = z[1+(c_index-1)*2];
area = 0.5 * r8_abs ( a_x * ( b_y - c_y )
+ b_x * ( c_y - a_y )
+ c_x * ( a_y - b_y ) );
ab_len = sqrt ( pow ( a_x - b_x, 2 ) + pow ( a_y - b_y, 2 ) );
bc_len = sqrt ( pow ( b_x - c_x, 2 ) + pow ( b_y - c_y, 2 ) );
ca_len = sqrt ( pow ( c_x - a_x, 2 ) + pow ( c_y - a_y, 2 ) );
//
// Take care of a ridiculous special case.
//
if ( ab_len == 0.0 && bc_len == 0.0 && ca_len == 0.0 )
{
a_angle = 2.0 * pi / 3.0;
b_angle = 2.0 * pi / 3.0;
c_angle = 2.0 * pi / 3.0;
}
else
{
if ( ca_len == 0.0 || ab_len == 0.0 )
{
a_angle = pi;
}
else
{
a_angle = r8_acos (
( ca_len * ca_len + ab_len * ab_len - bc_len * bc_len )
/ ( 2.0 * ca_len * ab_len ) );
}
if ( ab_len == 0.0 || bc_len == 0.0 )
{
b_angle = pi;
}
else
{
b_angle = r8_acos (
( ab_len * ab_len + bc_len * bc_len - ca_len * ca_len )
/ ( 2.0 * ab_len * bc_len ) );
}
if ( bc_len == 0.0 || ca_len == 0.0 )
{
c_angle = pi;
}
else
{
c_angle = r8_acos (
( bc_len * bc_len + ca_len * ca_len - ab_len * ab_len )
/ ( 2.0 * bc_len * ca_len ) );
}
}
*alpha_min = r8_min ( *alpha_min, a_angle );
*alpha_min = r8_min ( *alpha_min, b_angle );
*alpha_min = r8_min ( *alpha_min, c_angle );
*alpha_ave = *alpha_ave + *alpha_min;
*alpha_area = *alpha_area + area * *alpha_min;
area_total = area_total + area;
}
*alpha_ave = *alpha_ave / ( double ) ( triangle_num );
*alpha_area = *alpha_area / area_total;
//
// Normalize angles from [0,pi/3] radians into qualities in [0,1].
//
*alpha_min = *alpha_min * 3.0 / pi;
*alpha_ave = *alpha_ave * 3.0 / pi;
*alpha_area = *alpha_area * 3.0 / pi;
return;
}
//****************************************************************************80
double angle_rad_2d ( double p1[2], double p2[2], double p3[2] )
//****************************************************************************80
//
// Purpose:
//
// ANGLE_RAD_2D returns the angle in radians swept out between two rays in 2D.
//
// Discussion:
//
// ANGLE_RAD_2D ( P1, P2, P3 ) + ANGLE_RAD_2D ( P3, P2, P1 ) = 2 * PI
//
// P1
// /
// /
// /
// /
// P2--------->P3
//
// Modified:
//
// 24 June 2005
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, double P1[2], P2[2], P3[2], define the rays
// P1 - P2 and P3 - P2 which define the angle.
//
// Output, double ANGLE_RAD_3D, the angle between the two rays,
// in radians. This value will always be between 0 and 2*PI. If either
// ray has zero length, then the angle is returned as zero.
//
{
# define DIM_NUM 2
double p[DIM_NUM];
double pi = 3.141592653589793;
double value;
p[0] = ( p3[0] - p2[0] ) * ( p1[0] - p2[0] )
+ ( p3[1] - p2[1] ) * ( p1[1] - p2[1] );
p[1] = ( p3[0] - p2[0] ) * ( p1[1] - p2[1] )
- ( p3[1] - p2[1] ) * ( p1[0] - p2[0] );
if ( p[0] == 0.0 && p[1] == 0.0 )
{
value = 0.0;
return value;
}
value = atan2 ( p[1], p[0] );
if ( value < 0.0 )
{
value = value + 2.0 * pi;
}
return value;
# undef DIM_NUM
}
//****************************************************************************80
int diaedg ( double x0, double y0, double x1, double y1, double x2, double y2,
double x3, double y3 )
//****************************************************************************80
//
// Purpose:
//
// DIAEDG chooses a diagonal edge.
//
// Discussion:
//
// The routine determines whether 0--2 or 1--3 is the diagonal edge
// that should be chosen, based on the circumcircle criterion, where
// (X0,Y0), (X1,Y1), (X2,Y2), (X3,Y3) are the vertices of a simple
// quadrilateral in counterclockwise order.
//
// Modified:
//
// 28 August 2003
//
// Author:
//
// Original FORTRAN77 version by Barry Joe.
// C++ version by John Burkardt.
//
// Reference:
//
// Barry Joe,
// GEOMPACK - a software package for the generation of meshes
// using geometric algorithms,
// Advances in Engineering Software,
// Volume 13, pages 325-331, 1991.
//
// Parameters:
//
// Input, double X0, Y0, X1, Y1, X2, Y2, X3, Y3, the coordinates of the
// vertices of a quadrilateral, given in counter clockwise order.
//
// Output, int DIAEDG, chooses a diagonal:
// +1, if diagonal edge 02 is chosen;
// -1, if diagonal edge 13 is chosen;
// 0, if the four vertices are cocircular.
//
{
double ca;
double cb;
double dx10;
double dx12;
double dx30;
double dx32;
double dy10;
double dy12;
double dy30;
double dy32;
double s;
double tol;
double tola;
double tolb;
int value;
tol = 100.0 * r8_epsilon ( );
dx10 = x1 - x0;
dy10 = y1 - y0;
dx12 = x1 - x2;
dy12 = y1 - y2;
dx30 = x3 - x0;
dy30 = y3 - y0;
dx32 = x3 - x2;
dy32 = y3 - y2;
tola = tol * r8_max ( fabs ( dx10 ),
r8_max ( fabs ( dy10 ),
r8_max ( fabs ( dx30 ), fabs ( dy30 ) ) ) );
tolb = tol * r8_max ( fabs ( dx12 ),
r8_max ( fabs ( dy12 ),
r8_max ( fabs ( dx32 ), fabs ( dy32 ) ) ) );
ca = dx10 * dx30 + dy10 * dy30;
cb = dx12 * dx32 + dy12 * dy32;
if ( tola < ca && tolb < cb )
{
value = -1;
}
else if ( ca < -tola && cb < -tolb )
{
value = 1;
}
else
{
tola = r8_max ( tola, tolb );
s = ( dx10 * dy30 - dx30 * dy10 ) * cb
+ ( dx32 * dy12 - dx12 * dy32 ) * ca;
if ( tola < s )
{
value = -1;
}
else if ( s < -tola )
{
value = 1;
}
else
{
value = 0;
}
}
return value;
}
//****************************************************************************80
int i4_max ( int i1, int i2 )
//****************************************************************************80
//
// Purpose:
//
// I4_MAX returns the maximum of two I4's.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 13 October 1998
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int I1, I2, are two integers to be compared.
//
// Output, int I4_MAX, the larger of I1 and I2.
//
{
int value;
if ( i2 < i1 )
{
value = i1;
}
else
{
value = i2;
}
return value;
}
//****************************************************************************80
int i4_min ( int i1, int i2 )
//****************************************************************************80
//
// Purpose:
//
// I4_MIN returns the minimum of two I4's.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 13 October 1998
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int I1, I2, two integers to be compared.
//
// Output, int I4_MIN, the smaller of I1 and I2.
//
{
int value;
if ( i1 < i2 )
{
value = i1;
}
else
{
value = i2;
}
return value;
}
//****************************************************************************80
int i4_modp ( int i, int j )
//****************************************************************************80
//
// Purpose:
//
// I4_MODP returns the nonnegative remainder of I4 division.
//
// Discussion:
//
// If
// NREM = I4_MODP ( I, J )
// NMULT = ( I - NREM ) / J
// then
// I = J * NMULT + NREM
// where NREM is always nonnegative.
//
// The MOD function computes a result with the same sign as the
// quantity being divided. Thus, suppose you had an angle A,
// and you wanted to ensure that it was between 0 and 360.
// Then mod(A,360) would do, if A was positive, but if A
// was negative, your result would be between -360 and 0.
//
// On the other hand, I4_MODP(A,360) is between 0 and 360, always.
//
// I J MOD I4_MODP I4_MODP Factorization
//
// 107 50 7 7 107 = 2 * 50 + 7
// 107 -50 7 7 107 = -2 * -50 + 7
// -107 50 -7 43 -107 = -3 * 50 + 43
// -107 -50 -7 43 -107 = 3 * -50 + 43
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 26 May 1999
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int I, the number to be divided.
//
// Input, int J, the number that divides I.
//
// Output, int I4_MODP, the nonnegative remainder when I is
// divided by J.
//
{
int value;
if ( j == 0 )
{
cout << "\n";
cout << "I4_MODP - Fatal error!\n";
cout << " I4_MODP ( I, J ) called with J = " << j << "\n";
exit ( 1 );
}
value = i % j;
if ( value < 0 )
{
value = value + abs ( j );
}
return value;
}
//****************************************************************************80
int i4_sign ( int i )
//****************************************************************************80
//
// Purpose:
//
// I4_SIGN returns the sign of an I4.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 27 March 2004
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int I, the integer whose sign is desired.
//
// Output, int I4_SIGN, the sign of I.
{
int value;
if ( i < 0 )
{
value = -1;
}
else
{
value = 1;
}
return value;
}
//****************************************************************************80
int i4_wrap ( int ival, int ilo, int ihi )
//****************************************************************************80
//
// Purpose:
//
// I4_WRAP forces an I4 to lie between given limits by wrapping.
//
// Example:
//
// ILO = 4, IHI = 8
//
// I Value
//
// -2 8
// -1 4
// 0 5
// 1 6
// 2 7
// 3 8
// 4 4
// 5 5
// 6 6
// 7 7
// 8 8
// 9 4
// 10 5
// 11 6
// 12 7
// 13 8
// 14 4
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 19 August 2003
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int IVAL, an integer value.
//
// Input, int ILO, IHI, the desired bounds for the integer value.
//
// Output, int I4_WRAP, a "wrapped" version of IVAL.
//
{
int jhi;
int jlo;
int value;
int wide;
jlo = i4_min ( ilo, ihi );
jhi = i4_max ( ilo, ihi );
wide = jhi + 1 - jlo;
if ( wide == 1 )
{
value = jlo;
}
else
{
value = jlo + i4_modp ( ival - jlo, wide );
}
return value;
}
//****************************************************************************80
void i4mat_transpose_print ( int m, int n, int a[], string title )
//****************************************************************************80
//
// Purpose:
//
// I4MAT_TRANSPOSE_PRINT prints an I4MAT, transposed.
//
// Discussion:
//
// An I4MAT is an MxN array of I4's, stored by (I,J) -> [I+J*M].
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 31 January 2005
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int M, the number of rows in A.
//
// Input, int N, the number of columns in A.
//
// Input, int A[M*N], the M by N matrix.
//
// Input, string TITLE, a title.
//
{
i4mat_transpose_print_some ( m, n, a, 1, 1, m, n, title );
return;
}
//****************************************************************************80
void i4mat_transpose_print_some ( int m, int n, int a[], int ilo, int jlo,
int ihi, int jhi, string title )
//****************************************************************************80
//
// Purpose:
//
// I4MAT_TRANSPOSE_PRINT_SOME prints some of an I4MAT, transposed.
//
// Discussion:
//
// An I4MAT is an MxN array of I4's, stored by (I,J) -> [I+J*M].
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 20 August 2010
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int M, the number of rows of the matrix.
// M must be positive.
//
// Input, int N, the number of columns of the matrix.
// N must be positive.
//
// Input, int A[M*N], the matrix.
//
// Input, int ILO, JLO, IHI, JHI, designate the first row and
// column, and the last row and column to be printed.
//
// Input, string TITLE, a title.
//
{
# define INCX 10
int i;
int i2hi;
int i2lo;
int j;
int j2hi;
int j2lo;
cout << "\n";
cout << title << "\n";
if ( m <= 0 || n <= 0 )
{
cout << "\n";
cout << " (None)\n";
return;
}
//
// Print the columns of the matrix, in strips of INCX.
//
for ( i2lo = ilo; i2lo <= ihi; i2lo = i2lo + INCX )
{
i2hi = i2lo + INCX - 1;
i2hi = i4_min ( i2hi, m );
i2hi = i4_min ( i2hi, ihi );
cout << "\n";
//
// For each row I in the current range...
//
// Write the header.
//
cout << " Row: ";
for ( i = i2lo; i <= i2hi; i++ )
{
cout << setw(6) << i - 1 << " ";
}
cout << "\n";
cout << " Col\n";
cout << "\n";
//
// Determine the range of the rows in this strip.
//
j2lo = i4_max ( jlo, 1 );
j2hi = i4_min ( jhi, n );
for ( j = j2lo; j <= j2hi; j++ )
{
//
// Print out (up to INCX) entries in column J, that lie in the current strip.
//
cout << setw(5) << j - 1 << ":";
for ( i = i2lo; i <= i2hi; i++ )
{
cout << setw(6) << a[i-1+(j-1)*m] << " ";
}
cout << "\n";
}
}
return;
# undef INCX
}
//****************************************************************************80
void i4vec_heap_d ( int n, int a[] )
//****************************************************************************80
//
// Purpose:
//
// I4VEC_HEAP_D reorders an I4VEC into a descending heap.
//
// Discussion:
//
// A heap is an array A with the property that, for every index J,
// A[J] >= A[2*J+1] and A[J] >= A[2*J+2], (as long as the indices
// 2*J+1 and 2*J+2 are legal).
//
// Diagram:
//
// A(0)
// / \ .
// A(1) A(2) .
// / \ / \ .
// A(3) A(4) A(5) A(6) .
// / \ / \ .
// A(7) A(8) A(9) A(10) .
//
// Modified:
//
// 30 April 1999
//
// Author:
//
// John Burkardt
//
// Reference:
//
// Albert Nijenhuis, Herbert Wilf,
// Combinatorial Algorithms,
// Academic Press, 1978, second edition,
// ISBN 0-12-519260-6.
//
// Parameters:
//
// Input, int N, the size of the input array.
//
// Input/output, int A[N].
// On input, an unsorted array.
// On output, the array has been reordered into a heap.
//
{
int i;
int ifree;
int key;
int m;
//
// Only nodes (N/2)-1 down to 0 can be "parent" nodes.
//
for ( i = (n/2)-1; 0 <= i; i-- )
{
//
// Copy the value out of the parent node.
// Position IFREE is now "open".
//
key = a[i];
ifree = i;
for ( ;; )
{
//
// Positions 2*IFREE + 1 and 2*IFREE + 2 are the descendants of position
// IFREE. (One or both may not exist because they equal or exceed N.)
//
m = 2 * ifree + 1;
//
// Does the first position exist?
//
if ( n <= m )
{
break;
}
else
{
//
// Does the second position exist?
//
if ( m + 1 < n )
{
//
// If both positions exist, take the larger of the two values,
// and update M if necessary.
//
if ( a[m] < a[m+1] )
{
m = m + 1;
}
}
//
// If the large descendant is larger than KEY, move it up,
// and update IFREE, the location of the free position, and
// consider the descendants of THIS position.
//
if ( key < a[m] )
{
a[ifree] = a[m];
ifree = m;
}
else
{
break;
}
}
}
//
// When you have stopped shifting items up, return the item you
// pulled out back to the heap.
//
a[ifree] = key;
}
return;
}
//****************************************************************************80
int *i4vec_indicator_new ( int n )
//****************************************************************************80
//
// Purpose:
//
// I4VEC_INDICATOR_NEW sets an I4VEC to the indicator vector.
//
// Discussion:
//
// An I4VEC is a vector of I4's.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 June 2009
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int N, the number of elements of A.
//
// Output, int I4VEC_INDICATOR_NEW[N], the array.
//
{
int *a;
int i;
a = new int[n];
for ( i = 0; i < n; i++ )
{
a[i] = i + 1;
}
return a;
}
//****************************************************************************80
int i4vec_min ( int n, int a[] )
//****************************************************************************80
//
// Purpose:
//
// I4VEC_MIN returns the value of the minimum element in an I4VEC.
//
// Discussion:
//
// An I4VEC is a vector of I4's.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 17 May 2003
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int N, the number of entries in the array.
//
// Input, int A[N], the array to be checked.
//
// Output, int I4VEC_MIN, the value of the minimum element. This
// is set to 0 if N <= 0.
//
{
int i;
int value;
if ( n <= 0 )
{
return 0;
}