delete[] array;
}
-template<class T>
-T smooth_min(T x, T y) {
- T z = exp(x - y);
- return 0.5 * (x + y - (x - y)/(1 + 1/z) - (y - x)/(1 + z));
-}
-
template <class T>
void write_var(ostream *os, const T *x) { os->write((char *) x, sizeof(T)); }
template <class T>
void read_var(istream *is, T *x) { is->read((char *) x, sizeof(T)); }
-template <class T>
-void grow(int *nb_max, int nb, T** current, int factor) {
- ASSERT(*nb_max > 0);
- if(nb == *nb_max) {
- T *tmp = new T[*nb_max * factor];
- memcpy(tmp, *current, *nb_max * sizeof(T));
- delete[] *current;
- *current = tmp;
- *nb_max *= factor;
- }
-}
-
template <class T>
inline T sq(T x) {
return x * x;
return log(x)/log(2.0);
}
-inline scalar_t xi(scalar_t x) {
- if(x <= 0.0) return 0.0;
- else return - x * log(x)/log(2.0);
-}
-
-scalar_t discrete_entropy(int *n, int nb);
-
-char *next_word(char *buffer, char *r, int buffer_size);
-
-void random_permutation(int *val, int nb);
-void tag_subset(bool *val, int nb_total, int nb_to_tag);
-
-struct Couple {
- int index;
- scalar_t value;
-};
-
-int compare_couple(const void *a, const void *b);
-
#endif