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 
x
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
Definition: gnuplot_common_settings.hh:12
metis_rcode
int metis_rcode(int sigrval)
Definition: libmetis/util.c:123
SIGMEM
#define SIGMEM
Definition: gk_defs.h:37
n
int n
Definition: BiCGSTAB_simple.cpp:1
METIS_ERROR
@ METIS_ERROR
Definition: include/metis.h:257
METIS_OK
@ METIS_OK
Definition: include/metis.h:254
rargmax2
idx_t rargmax2(size_t n, real_t *x)
Definition: libmetis/util.c:63
InitRandom
void InitRandom(idx_t seed)
Definition: libmetis/util.c:21
incx
RealScalar RealScalar int * incx
Definition: level1_cplx_impl.h:29
y
Scalar * y
Definition: level1_cplx_impl.h:124
real_t
float real_t
Definition: include/metis.h:132
iargmax2_nrm
idx_t iargmax2_nrm(size_t n, idx_t *x, real_t *y)
Definition: libmetis/util.c:93
iargmax_nrm
idx_t iargmax_nrm(size_t n, idx_t *x, real_t *y)
Definition: libmetis/util.c:31
metislib.h
iargmax_strd
idx_t iargmax_strd(size_t n, idx_t *x, idx_t incx)
Definition: libmetis/util.c:46
max
#define max(a, b)
Definition: datatypes.h:20
METIS_ERROR_MEMORY
@ METIS_ERROR_MEMORY
Definition: include/metis.h:256
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
isrand
#define isrand
Definition: gklib_rename.h:71
idx_t
int32_t idx_t
Definition: include/metis.h:101


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:43:07