From b715671988a4f3e476586df52fa3bf052cce7f80 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Thu, 05 Dec 2013 21:17:16 +0000
Subject: [PATCH] Works well on MNIST
---
src/utils.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/src/utils.c b/src/utils.c
index 8229b2d..3b8b5a8 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -180,6 +180,35 @@
sigma = sqrt(variance_array(a,n));
}
+void translate_array(double *a, int n, double s)
+{
+ int i;
+ for(i = 0; i < n; ++i){
+ a[i] += s;
+ }
+}
+
+void scale_array(double *a, int n, double s)
+{
+ int i;
+ for(i = 0; i < n; ++i){
+ a[i] *= s;
+ }
+}
+int max_index(double *a, int n)
+{
+ if(n <= 0) return -1;
+ int i, max_i = 0;
+ double max = a[0];
+ for(i = 1; i < n; ++i){
+ if(a[i] > max){
+ max = a[i];
+ max_i = i;
+ }
+ }
+ return max_i;
+}
+
double rand_normal()
{
int i;
--
Gitblit v1.10.0