math_functions.h
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00042 #include "fastlib/fastlib.h"
00043 
00044 
00045 
00061 void min_element(Matrix& element, index_t *indices) {
00062         
00063   index_t last = element.n_cols() - 1;
00064   index_t first, lowest;
00065   index_t i;
00066         
00067   for (i = 0; i < element.n_rows(); i++) {
00068                 
00069     first = lowest = 0;
00070     if (first == last) {
00071       indices[i] = last;
00072     }
00073     while (++first <= last) {
00074       if (element.get(i, first) < element.get(i, lowest)) {
00075         lowest = first;
00076       }
00077     }
00078     indices[i] = lowest;
00079   }
00080   return;
00081 }
00082 
00095 int max_element_index(float *array, int length) {
00096   
00097   int last = length - 1;
00098   int first = 0;
00099   int highest = 0;
00100         
00101   if (first == last) {
00102     return last;
00103   }
00104   while (++first <= last) {
00105     if (array[first] > array[highest]) {
00106       highest = first;
00107     }
00108   }
00109   return highest;
00110 }
00111 
00124 int max_element_index(ArrayList<float>& array){
00125 
00126   int last = array.size() - 1;
00127   int first = 0;
00128   int highest = 0;
00129 
00130   if (first == last) {
00131     return last;
00132   }
00133   while (++first <= last) {
00134     if (array[first] > array[highest]) {
00135       highest = first;
00136     }
00137   }
00138   return highest;
00139 }
00140 
00153 int max_element_index(ArrayList<double>& array) {
00154 
00155   int last = array.size() - 1;
00156   int first = 0;
00157   int highest = 0;
00158 
00159   if (first == last) {
00160     return last;
00161   }
00162   while (++first <= last) {
00163     if(array[first] > array[highest]) {
00164       highest = first;
00165     }
00166   }
00167   return highest;
00168 }
00169