libmetis/util.c
Go to the documentation of this file.
1 /*
2  * Copyright 1997, Regents of the University of Minnesota
3  *
4  * util.c
5  *
6  * This function contains various utility routines
7  *
8  * Started 9/28/95
9  * George
10  *
11  * $Id: util.c 10495 2011-07-06 16:04:45Z karypis $
12  */
13 
14 #include "metislib.h"
15 
16 
17 /*************************************************************************/
20 /*************************************************************************/
21 void InitRandom(idx_t seed)
22 {
23  isrand((seed == -1 ? 4321 : seed));
24 }
25 
26 
27 /*************************************************************************/
30 /*************************************************************************/
32 {
33  idx_t i, max=0;
34 
35  for (i=1; i<n; i++)
36  max = (x[i]*y[i] > x[max]*y[max] ? i : max);
37 
38  return max;
39 }
40 
41 
42 /*************************************************************************/
45 /*************************************************************************/
47 {
48  size_t i, max=0;
49 
50  n *= incx;
51  for (i=incx; i<n; i+=incx)
52  max = (x[i] > x[max] ? i : max);
53 
54  return max/incx;
55 }
56 
57 
58 /*************************************************************************/
62 /*************************************************************************/
63 idx_t rargmax2(size_t n, real_t *x)
64 {
65  size_t i, max1, max2;
66 
67  if (x[0] > x[1]) {
68  max1 = 0;
69  max2 = 1;
70  }
71  else {
72  max1 = 1;
73  max2 = 0;
74  }
75 
76  for (i=2; i<n; i++) {
77  if (x[i] > x[max1]) {
78  max2 = max1;
79  max1 = i;
80  }
81  else if (x[i] > x[max2])
82  max2 = i;
83  }
84 
85  return max2;
86 }
87 
88 
89 /*************************************************************************/
92 /*************************************************************************/
94 {
95  size_t i, max1, max2;
96 
97  if (x[0]*y[0] > x[1]*y[1]) {
98  max1 = 0;
99  max2 = 1;
100  }
101  else {
102  max1 = 1;
103  max2 = 0;
104  }
105 
106  for (i=2; i<n; i++) {
107  if (x[i]*y[i] > x[max1]*y[max1]) {
108  max2 = max1;
109  max1 = i;
110  }
111  else if (x[i]*y[i] > x[max2]*y[max2])
112  max2 = i;
113  }
114 
115  return max2;
116 }
117 
118 
119 /*************************************************************************/
122 /*************************************************************************/
123 int metis_rcode(int sigrval)
124 {
125  switch (sigrval) {
126  case 0:
127  return METIS_OK;
128  break;
129  case SIGMEM:
130  return METIS_ERROR_MEMORY;
131  break;
132  default:
133  return METIS_ERROR;
134  break;
135  }
136 }
137 
138 
#define max(a, b)
Definition: datatypes.h:20
Scalar * y
#define SIGMEM
Definition: gk_defs.h:37
idx_t iargmax_strd(size_t n, idx_t *x, idx_t incx)
Definition: libmetis/util.c:46
RealScalar RealScalar int * incx
int n
idx_t iargmax2_nrm(size_t n, idx_t *x, real_t *y)
Definition: libmetis/util.c:93
int32_t idx_t
void InitRandom(idx_t seed)
Definition: libmetis/util.c:21
float real_t
idx_t iargmax_nrm(size_t n, idx_t *x, real_t *y)
Definition: libmetis/util.c:31
#define isrand
Definition: gklib_rename.h:71
idx_t rargmax2(size_t n, real_t *x)
Definition: libmetis/util.c:63
int metis_rcode(int sigrval)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:51:23