Created
July 16, 2015 17:02
-
-
Save sampsyo/c935defe90abcd08f264 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 615fc8bb5543bb2b88d4f97ebff74d1890f4dcc8 | |
Author: Adrian Sampson <adrian@radbox.org> | |
Date: Thu Jul 16 09:57:49 2015 -0700 | |
Remove all the ACCEPT stuff | |
diff --git a/svd3/common/calcSobel_dX.c b/svd3/common/calcSobel_dX.c | |
index 5dddfdb..0976948 100644 | |
--- a/svd3/common/calcSobel_dX.c | |
+++ b/svd3/common/calcSobel_dX.c | |
@@ -4,14 +4,13 @@ Author: Sravanthi Kota Venkata | |
#include <stdio.h> | |
#include <stdlib.h> | |
-#include <enerc.h> | |
#include "sdvbs_common.h" | |
F2D* calcSobel_dX(F2D* imageIn) | |
-{ accept_roi_begin(); | |
+{ | |
int rows, cols; | |
F2D *kernel_1, *kernel_2; | |
- APPROX float temp; | |
+ float temp; | |
int kernelSize, startCol, endCol, halfKernel, startRow, endRow, i, j, kernelSum; | |
int k, kernelSum_1, kernelSum_2; | |
F2D *imageOut, *tempOut; | |
@@ -53,7 +52,7 @@ F2D* calcSobel_dX(F2D* imageIn) | |
{ | |
temp += subsref(imageIn,i,j+k) * asubsref(kernel_2,k+halfKernel); | |
} | |
- subsref(tempOut,i,j) = (ENDORSE(temp))/kernelSum_2; | |
+ subsref(tempOut,i,j) = ((temp))/kernelSum_2; | |
} | |
} | |
@@ -66,14 +65,13 @@ F2D* calcSobel_dX(F2D* imageIn) | |
{ | |
temp += subsref(tempOut,(i+k),j) * asubsref(kernel_1,k+halfKernel); | |
} | |
- subsref(imageOut,i,j) = (ENDORSE(temp))/(float)kernelSum_1; | |
+ subsref(imageOut,i,j) = ((temp))/(float)kernelSum_1; | |
} | |
} | |
fFreeHandle(tempOut); | |
fFreeHandle(kernel_1); | |
fFreeHandle(kernel_2); | |
- accept_roi_end(); | |
return imageOut; | |
} | |
diff --git a/svd3/common/calcSobel_dY.c b/svd3/common/calcSobel_dY.c | |
index d8f9af2..c859cbc 100644 | |
--- a/svd3/common/calcSobel_dY.c | |
+++ b/svd3/common/calcSobel_dY.c | |
@@ -2,15 +2,13 @@ | |
Author: Sravanthi Kota Venkata | |
********************************/ | |
-#include<enerc.h> | |
#include "sdvbs_common.h" | |
F2D* calcSobel_dY(F2D* imageIn) | |
{ | |
- accept_roi_begin(); | |
int rows, cols; | |
I2D *kernel_1, *kernel_2; | |
- APPROX float temp; | |
+ float temp; | |
int kernelSize, startCol, endCol, halfKernel, startRow, endRow, i, j, kernelSum; | |
int k, kernelSum_2, outputRows, outputCols; | |
F2D *imageOut, *tempOut; | |
@@ -56,7 +54,7 @@ F2D* calcSobel_dY(F2D* imageIn) | |
{ | |
temp += subsref(imageIn,(i+k),j) * asubsref(kernel_1,k+halfKernel); | |
} | |
- subsref(tempOut,i,j) = (ENDORSE(temp))/kernelSum_1; | |
+ subsref(tempOut,i,j) = ((temp))/kernelSum_1; | |
} | |
} | |
@@ -69,10 +67,9 @@ F2D* calcSobel_dY(F2D* imageIn) | |
{ | |
temp += subsref(tempOut,i,j+k) * asubsref(kernel_2,k+halfKernel); | |
} | |
- subsref(imageOut,i,j) = (ENDORSE(temp))/(float)kernelSum_2; | |
+ subsref(imageOut,i,j) = ((temp))/(float)kernelSum_2; | |
} | |
} | |
- accept_roi_end(); | |
fFreeHandle(tempOut); | |
iFreeHandle(kernel_1); | |
iFreeHandle(kernel_2); | |
diff --git a/svd3/common/fMtimes.c b/svd3/common/fMtimes.c | |
index 5d1a663..a27370f 100644 | |
--- a/svd3/common/fMtimes.c | |
+++ b/svd3/common/fMtimes.c | |
@@ -2,15 +2,13 @@ | |
Author: Sravanthi Kota Venkata | |
********************************/ | |
-#include<enerc.h> | |
#include "sdvbs_common.h" | |
F2D* fMtimes(F2D* a, F2D* b) | |
{ | |
- accept_roi_begin(); | |
F2D *out; | |
int m, p, p1, n, i, j, k; | |
- APPROX float temp; | |
+ float temp; | |
m = a->height; | |
p = a->width; | |
@@ -29,10 +27,9 @@ F2D* fMtimes(F2D* a, F2D* b) | |
{ | |
temp += subsref(b,k,j) * subsref(a,i,k); | |
} | |
- subsref(out,i,j) = ENDORSE(temp); | |
+ subsref(out,i,j) = (temp); | |
} | |
} | |
- accept_roi_end(); | |
return out; | |
} | |
diff --git a/svd3/common/fSort.c b/svd3/common/fSort.c | |
index 25115f3..2b6fe9a 100644 | |
--- a/svd3/common/fSort.c | |
+++ b/svd3/common/fSort.c | |
@@ -2,7 +2,6 @@ | |
Author: Sravanthi Kota Venkata | |
********************************/ | |
-#include <enerc.h> | |
#include "sdvbs_common.h" | |
F2D* fSort(F2D* in, int dim) | |
@@ -14,27 +13,25 @@ F2D* fSort(F2D* in, int dim) | |
cols = in->width; | |
sorted = fDeepCopy(in); | |
- accept_roi_begin(); | |
for(k=0; k<cols; k++) | |
{ | |
for(i=0; i<rows; i++) | |
{ | |
for(j=i+1; j<rows; j++) | |
{ | |
- APPROX float sik, sjk; | |
+ float sik, sjk; | |
sik = subsref(sorted,i,k); | |
sjk = subsref(sorted,j,k); | |
- if(ENDORSE(sik) < ENDORSE(sjk)) | |
+ if((sik) < (sjk)) | |
{ | |
- temp = ENDORSE(sjk); | |
+ temp = (sjk); | |
sjk = sik; | |
sik = temp; | |
} | |
} | |
} | |
} | |
- accept_roi_end(); | |
return sorted; | |
} | |
diff --git a/svd3/common/fSum.c b/svd3/common/fSum.c | |
index c01e9e9..1a13915 100644 | |
--- a/svd3/common/fSum.c | |
+++ b/svd3/common/fSum.c | |
@@ -2,14 +2,13 @@ | |
Author: Sravanthi Kota Venkata | |
********************************/ | |
-#include <enerc.h> | |
#include "sdvbs_common.h" | |
F2D* fSum(F2D* inMat) | |
{ | |
F2D *outMat; | |
int rows, cols, i, j, k; | |
- APPROX float temp; | |
+ float temp; | |
int newRow, newCols; | |
int Rcols; | |
@@ -23,20 +22,19 @@ F2D* fSum(F2D* inMat) | |
outMat = fSetArray(1,Rcols,0); | |
- accept_roi_begin(); | |
if( cols == 1) | |
{ | |
temp = 0; | |
for( j=0; j<rows; j++) | |
temp = temp + subsref(inMat,j,0); | |
- asubsref(outMat,0) = ENDORSE(temp); | |
+ asubsref(outMat,0) = (temp); | |
} | |
else if( rows == 1) | |
{ | |
temp = 0; | |
for( j=0; j<cols; j++) | |
temp = temp + asubsref(inMat,j); | |
- asubsref(outMat,0) = ENDORSE(temp); | |
+ asubsref(outMat,0) = (temp); | |
} | |
else | |
{ | |
@@ -45,10 +43,9 @@ F2D* fSum(F2D* inMat) | |
temp = 0; | |
for( j=0; j<rows; j++) | |
temp = temp + subsref(inMat,j,i); | |
- asubsref(outMat,i) = ENDORSE(temp); | |
+ asubsref(outMat,i) = (temp); | |
} | |
} | |
- accept_roi_end(); | |
return outMat; | |
} | |
diff --git a/svd3/common/fSum2.c b/svd3/common/fSum2.c | |
index 0e53d6d..8006421 100644 | |
--- a/svd3/common/fSum2.c | |
+++ b/svd3/common/fSum2.c | |
@@ -2,14 +2,13 @@ | |
Author: Sravanthi Kota Venkata | |
********************************/ | |
-#include <enerc.h> | |
#include "sdvbs_common.h" | |
F2D* fSum2(F2D* inMat, int dir) | |
{ | |
F2D *outMat; | |
int rows, cols, i, j, k; | |
- APPROX float temp; | |
+ float temp; | |
int newRow, newCols; | |
rows = inMat->height; | |
@@ -28,7 +27,6 @@ F2D* fSum2(F2D* inMat, int dir) | |
outMat = fSetArray(newRow,newCols,0); | |
- accept_roi_begin(); | |
if(dir == 1) | |
{ | |
for (i=0; i<cols; i++) | |
@@ -36,7 +34,7 @@ F2D* fSum2(F2D* inMat, int dir) | |
temp = 0; | |
for( j=0; j<rows; j++) | |
temp = temp + subsref(inMat,j,i); | |
- asubsref(outMat,i) = ENDORSE(temp); | |
+ asubsref(outMat,i) = (temp); | |
} | |
} | |
else | |
@@ -46,11 +44,10 @@ F2D* fSum2(F2D* inMat, int dir) | |
temp = 0; | |
for( j=0; j<cols; j++) | |
temp = temp + subsref(inMat,i,j); | |
- subsref(outMat,i,0) = ENDORSE(temp); | |
+ subsref(outMat,i,0) = (temp); | |
} | |
} | |
- accept_roi_end(); | |
return outMat; | |
} | |
diff --git a/svd3/common/ifMtimes.c b/svd3/common/ifMtimes.c | |
index 2327afc..d8cd58a 100644 | |
--- a/svd3/common/ifMtimes.c | |
+++ b/svd3/common/ifMtimes.c | |
@@ -2,15 +2,13 @@ | |
Author: Sravanthi Kota Venkata | |
********************************/ | |
-#include <enerc.h> | |
#include "sdvbs_common.h" | |
F2D* ifMtimes(I2D* a, F2D* b) | |
{ | |
- accept_roi_begin(); | |
F2D *out; | |
int m, p, p1, n, i, j, k; | |
- APPROX float temp; | |
+ float temp; | |
m = a->height; | |
p = a->width; | |
@@ -30,10 +28,9 @@ F2D* ifMtimes(I2D* a, F2D* b) | |
{ | |
temp += subsref(b,k,j) * subsref(a,i,k); | |
} | |
- subsref(out,i,j) = ENDORSE(temp); | |
+ subsref(out,i,j) = (temp); | |
} | |
} | |
- accept_roi_end(); | |
return out; | |
} | |
diff --git a/svd3/common/imageBlur.c b/svd3/common/imageBlur.c | |
index dbc72bc..079bc36 100644 | |
--- a/svd3/common/imageBlur.c | |
+++ b/svd3/common/imageBlur.c | |
@@ -2,15 +2,13 @@ | |
Author: Sravanthi Kota Venkata | |
********************************/ | |
-#include <enerc.h> | |
#include "sdvbs_common.h" | |
F2D* imageBlur(I2D* imageIn) | |
{ | |
- accept_roi_begin(); | |
int rows, cols; | |
F2D *imageOut, *tempOut; | |
- APPROX float temp; | |
+ float temp; | |
I2D *kernel; | |
int k, kernelSize, startCol, endCol, halfKernel, startRow, endRow, i, j, kernelSum; | |
@@ -44,7 +42,7 @@ F2D* imageBlur(I2D* imageIn) | |
{ | |
temp += subsref(imageIn,i,j+k) * asubsref(kernel,k+halfKernel); | |
} | |
- subsref(tempOut,i,j) = (ENDORSE(temp))/kernelSum; | |
+ subsref(tempOut,i,j) = ((temp))/kernelSum; | |
} | |
} | |
@@ -57,10 +55,9 @@ F2D* imageBlur(I2D* imageIn) | |
{ | |
temp += subsref(tempOut,(i+k),j) * asubsref(kernel,k+halfKernel); | |
} | |
- subsref(imageOut,i,j) = (ENDORSE(temp))/kernelSum; | |
+ subsref(imageOut,i,j) = ((temp))/kernelSum; | |
} | |
} | |
- accept_roi_end(); | |
fFreeHandle(tempOut); | |
iFreeHandle(kernel); | |
diff --git a/svd3/common/imageResize.c b/svd3/common/imageResize.c | |
index e524e44..980dc0d 100644 | |
--- a/svd3/common/imageResize.c | |
+++ b/svd3/common/imageResize.c | |
@@ -2,7 +2,6 @@ | |
Author: Sravanthi Kota Venkata | |
********************************/ | |
-#include <enerc.h> | |
#include "sdvbs_common.h" | |
F2D* imageResize(F2D* imageIn) | |
@@ -10,7 +9,7 @@ F2D* imageResize(F2D* imageIn) | |
int m, k, rows, cols; | |
F2D *imageOut; | |
I2D *kernel; | |
- APPROX float tempVal; | |
+ float tempVal; | |
int kernelSize, startCol, endCol, halfKernel, startRow, endRow, i, j, kernelSum; | |
int outputRows, outputCols; | |
F2D *temp; | |
@@ -42,7 +41,6 @@ F2D* imageResize(F2D* imageIn) | |
startRow = 2; | |
endRow = rows - 2; | |
- accept_roi_begin(); | |
for(i=startRow; i<endRow; i++) | |
{ | |
m = 0; | |
@@ -53,7 +51,7 @@ F2D* imageResize(F2D* imageIn) | |
{ | |
tempVal += subsref(imageIn,i,j+k) * asubsref(kernel,k+halfKernel); | |
} | |
- subsref(temp,i,m) = (ENDORSE(tempVal))/kernelSum; | |
+ subsref(temp,i,m) = ((tempVal))/kernelSum; | |
m = m+1; | |
} | |
} | |
@@ -68,11 +66,10 @@ F2D* imageResize(F2D* imageIn) | |
{ | |
tempVal += subsref(temp,(i+k),j) * asubsref(kernel,k+halfKernel); | |
} | |
- subsref(imageOut,m,j) = ((ENDORSE(tempVal))/kernelSum); | |
+ subsref(imageOut,m,j) = (((tempVal))/kernelSum); | |
} | |
m = m+1; | |
} | |
- accept_roi_end(); | |
fFreeHandle(temp); | |
iFreeHandle(kernel); | |
diff --git a/svd3/common/sdvbs_common.h b/svd3/common/sdvbs_common.h | |
index be0c0ac..fe0f1a5 100644 | |
--- a/svd3/common/sdvbs_common.h | |
+++ b/svd3/common/sdvbs_common.h | |
@@ -8,7 +8,6 @@ Author: Sravanthi Kota Venkata | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
-#include <enerc.h> | |
typedef struct | |
{ | |
diff --git a/svd3/defs_and_types.h b/svd3/defs_and_types.h | |
index d93abad..d6cee03 100644 | |
--- a/svd3/defs_and_types.h | |
+++ b/svd3/defs_and_types.h | |
@@ -16,7 +16,7 @@ | |
* dicook@iastate.edu * | |
* * | |
************************************************************/ | |
-#include <enerc.h> | |
+ | |
#define PRECISION1 32768 | |
#define PRECISION2 16384 | |
@@ -35,7 +35,7 @@ | |
#define False 0 | |
typedef struct { | |
- APPROX float x, y, z; | |
+ float x, y, z; | |
} fcoords; | |
typedef struct { | |
@@ -47,13 +47,13 @@ typedef struct { | |
} icoords; | |
typedef struct { | |
- APPROX float min, max; | |
+ float min, max; | |
} lims; | |
/* grand tour history */ | |
typedef struct hist_rec { | |
struct hist_rec *prev, *next; | |
- APPROX float *basis[3]; | |
+ float *basis[3]; | |
int pos; | |
} hist_rec; | |
diff --git a/svd3/includes/enerc.h b/svd3/includes/enerc.h | |
deleted file mode 100644 | |
index bb2d704..0000000 | |
--- a/svd3/includes/enerc.h | |
+++ /dev/null | |
@@ -1,30 +0,0 @@ | |
-#ifndef ENERC_H | |
-#define ENERC_H | |
- | |
-#define TAG_ENDORSEMENT 39945 | |
-#define TAG_DEDORSEMENT 39946 | |
- | |
-#define APPROX __attribute__((qual("approx"))) | |
-#define ENDORSE(e) (_Pragma("clang diagnostic push") \ | |
- _Pragma("clang diagnostic ignored \"-Wunused-value\"") \ | |
- TAG_ENDORSEMENT \ | |
- _Pragma("clang diagnostic pop") \ | |
- , (e) \ | |
- ) | |
-#define DEDORSE(e) (_Pragma("clang diagnostic push") \ | |
- _Pragma("clang diagnostic ignored \"-Wunused-value\"") \ | |
- TAG_DEDORSEMENT \ | |
- _Pragma("clang diagnostic pop") \ | |
- , (e) \ | |
- ) | |
- | |
-// Benchmark instrumentation. | |
-#ifdef __cplusplus | |
-extern "C" void accept_roi_begin(); | |
-extern "C" void accept_roi_end(); | |
-#else | |
-void accept_roi_begin(); | |
-void accept_roi_end(); | |
-#endif | |
- | |
-#endif | |
diff --git a/svd3/main.c b/svd3/main.c | |
index f552a68..ab5c138 100644 | |
--- a/svd3/main.c | |
+++ b/svd3/main.c | |
@@ -101,9 +101,7 @@ int main(int argc, char ** argv) | |
int temp = remove("result_U.txt"); | |
fWriteMatrix(u, "result", "result_U.txt"); | |
- /* | |
fWriteMatrix(v, "result", "result_V.txt"); | |
- */ | |
//fWriteMatrix(v, "result", "result_U.txt"); | |
//until here | |
diff --git a/svd3/svd.c b/svd3/svd.c | |
index 9467577..64e817f 100644 | |
--- a/svd3/svd.c | |
+++ b/svd3/svd.c | |
@@ -18,22 +18,20 @@ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
-#include <enerc.h> | |
+ | |
#include "common/sdvbs_common.h" | |
#include "defs_and_types.h" | |
-static APPROX double PYTHAG(APPROX double a, APPROX double b) | |
+static double PYTHAG(double a, double b) | |
{ | |
- accept_roi_begin(); | |
- APPROX double at, bt, ct, result; | |
- at = fabs((ENDORSE(a))); | |
- bt = fabs((ENDORSE(b))); | |
+ double at, bt, ct, result; | |
+ at = fabs(((a))); | |
+ bt = fabs(((b))); | |
- if (ENDORSE(at) > ENDORSE(bt)) { ct = bt / at; result = at * sqrt(1.0 + ct * ct); } | |
- else if (ENDORSE(bt) > 0.0) { ct = at / bt; result = bt * sqrt(1.0 + ct * ct); } | |
+ if ((at) > (bt)) { ct = bt / at; result = at * sqrt(1.0 + ct * ct); } | |
+ else if ((bt) > 0.0) { ct = at / bt; result = bt * sqrt(1.0 + ct * ct); } | |
else result = 0.0; | |
return(result); | |
- accept_roi_end(); | |
} | |
#define a(i,j) subsref(input, i, j) | |
@@ -42,12 +40,11 @@ static APPROX double PYTHAG(APPROX double a, APPROX double b) | |
int svd(F2D *input, F2D *sOut, F2D *vOut) | |
{ | |
- accept_roi_begin(); | |
int flag, i, its, j, jj, k, l, nm; | |
double c, f, h, x, y, z; | |
double anorm = 0.0, g = 0.0; | |
- APPROX double s, scale = 0.0; | |
- APPROX double *rv1; | |
+ double s, scale = 0.0; | |
+ double *rv1; | |
int m = input->height; | |
int n = input->width; | |
@@ -71,18 +68,18 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
{ | |
for (k = i; k < m; k++) | |
scale += fabs((double)a(k, i)); | |
- if (ENDORSE(scale)) | |
+ if ((scale)) | |
{ | |
for (k = i; k < m; k++) | |
{ | |
- a(k,i) = (float)((double)a(k,i)/(ENDORSE(scale))); | |
+ a(k,i) = (float)((double)a(k,i)/((scale))); | |
s += ((double)a(k,i) * (double)a(k,i)); | |
} | |
f = (double)a(i,i); | |
//adding code | |
- double temp = ENDORSE(s); | |
+ double temp = (s); | |
g = -SIGN(sqrt(temp), f); | |
- h = f * g - (ENDORSE(s)); | |
+ h = f * g - ((s)); | |
a(i,i) = (float)(f - g); | |
if (i != n - 1) | |
{ | |
@@ -90,16 +87,16 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
{ | |
for (s = 0.0, k = i; k < m; k++) | |
s += ((double)a(k,i) * (double)a(k,j)); | |
- f = (ENDORSE(s)) / h; | |
+ f = ((s)) / h; | |
for (k = i; k < m; k++) | |
a(k,j) += (float)(f * (double)a(k,i)); | |
} | |
} | |
for (k = i; k < m; k++) | |
- a(k,i) = (float)((double)(a(k,i)*(ENDORSE(scale)))); | |
+ a(k,i) = (float)((double)(a(k,i)*((scale)))); | |
} | |
} | |
- w(i) = (float)(ENDORSE(scale * g)); | |
+ w(i) = (float)((scale * g)); | |
/* right-hand reduction */ | |
g = 0.0; | |
@@ -108,19 +105,19 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
{ | |
for (k = l; k < n; k++) | |
scale += fabs((double)a(i,k)); | |
- if (ENDORSE(scale)) | |
+ if ((scale)) | |
{ | |
for (k = l; k < n; k++) | |
{ | |
- a(i,k) = (float)((double)(a(i,k)/(ENDORSE(scale)))); | |
+ a(i,k) = (float)((double)(a(i,k)/((scale)))); | |
s += ((double)a(i,k) * (double)a(i,k)); | |
} | |
f = (double)a(i,l); | |
//adding code | |
- double temp = ENDORSE(s); | |
+ double temp = (s); | |
g = -SIGN(sqrt(temp), f); | |
- h = f * g - (ENDORSE(s)); | |
+ h = f * g - ((s)); | |
a(i,l) = (float)(f - g); | |
for (k = l; k < n; k++) | |
rv1[k] = (double)(a(i,k) / h); | |
@@ -131,14 +128,14 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
for (s = 0.0, k = l; k < n; k++) | |
s += ((double)a(j,k) * (double)a(i,k)); | |
for (k = l; k < n; k++) | |
- a(j,k) += (float)(ENDORSE(s * rv1[k])); | |
+ a(j,k) += (float)((s * rv1[k])); | |
} | |
} | |
for (k = l; k < n; k++) | |
- a(i,k) = (float)((double)(ENDORSE(a(i,k)*scale))); | |
+ a(i,k) = (float)((double)((a(i,k)*scale))); | |
} | |
} | |
- float temp = ENDORSE(rv1[i]); | |
+ float temp = (rv1[i]); | |
anorm = MAX(anorm, (fabs((double)w(i)) + fabs(temp))); | |
} | |
@@ -147,7 +144,7 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
{ | |
if (i < n - 1) | |
{ | |
- if (ENDORSE(g)) | |
+ if ((g)) | |
{ | |
for (j = l; j < n; j++) | |
v(j,i) = (float)(((double)a(i,j) / (double)( (a(i,l)) / g))); | |
@@ -157,14 +154,14 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
for (s = 0.0, k = l; k < n; k++) | |
s += ((double)a(i,k) * (double)v(k,j)); | |
for (k = l; k < n; k++) | |
- v(k,j) += (float)(ENDORSE(s * (double)v(k,i))); | |
+ v(k,j) += (float)((s * (double)v(k,i))); | |
} | |
} | |
for (j = l; j < n; j++) | |
v(i,j) = v(j,i) = 0.0; | |
} | |
v(i,i) = 1.0; | |
- g = ENDORSE(rv1[i]); | |
+ g = (rv1[i]); | |
l = i; | |
} | |
@@ -185,7 +182,7 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
{ | |
for (s = 0.0, k = l; k < m; k++) | |
s += ((double)a(k,i) * (double)a(k,j)); | |
- f = ((ENDORSE(s)) / (double)a(i,i)) * g; | |
+ f = (((s)) / (double)a(i,i)) * g; | |
for (k = i; k < m; k++) | |
a(k,j) += (float)(f * (double)a(k,i)); | |
} | |
@@ -210,13 +207,13 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
for (l = k; l >= 0; l--) | |
{ /* test for splitting */ | |
nm = l - 1; | |
- float temp = ENDORSE(rv1[l]); | |
+ float temp = (rv1[l]); | |
if (fabs(temp) + anorm == anorm) | |
{ | |
flag = 0; | |
break; | |
} | |
- if (fabs((double)w(nm)) + ENDORSE(anorm) == ENDORSE(anorm)) | |
+ if (fabs((double)w(nm)) + (anorm) == (anorm)) | |
break; | |
} | |
if (flag) | |
@@ -225,11 +222,11 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
s = 1.0; | |
for (i = l; i <= k; i++) | |
{ | |
- f = (ENDORSE(s)) * ENDORSE(rv1[i]); | |
+ f = ((s)) * (rv1[i]); | |
if (fabs(f) + anorm != anorm) | |
{ | |
g = (double)w(i); | |
- h = ENDORSE(PYTHAG(f, g)); | |
+ h = (PYTHAG(f, g)); | |
w(i) = (float)h; | |
h = 1.0 / h; | |
c = g * h; | |
@@ -238,8 +235,8 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
{ | |
y = (double)a(j,nm); | |
z = (double)a(j,i); | |
- a(j,nm) = (float)(ENDORSE(y * c + z * s)); | |
- a(j,i) = (float)(ENDORSE(z * c - y * s)); | |
+ a(j,nm) = (float)((y * c + z * s)); | |
+ a(j,i) = (float)((z * c - y * s)); | |
} | |
} | |
} | |
@@ -265,10 +262,10 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
x = (double)w(l); | |
nm = k - 1; | |
y = (double)w(nm); | |
- g = ENDORSE(rv1[nm]); | |
- h = ENDORSE(rv1[k]); | |
+ g = (rv1[nm]); | |
+ h = (rv1[k]); | |
f = ((y - z) * (y + z) + (g - h) * (g + h)) / (2.0 * h * y); | |
- g = ENDORSE(PYTHAG(f, 1.0)); | |
+ g = (PYTHAG(f, 1.0)); | |
f = ((x - z) * (x + z) + h * ((y / (f + SIGN(g, f))) - h)) / x; | |
/* next QR transformation */ | |
@@ -277,26 +274,26 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
for (j = l; j <= nm; j++) | |
{ | |
i = j + 1; | |
- g = ENDORSE(rv1[i]); | |
+ g = (rv1[i]); | |
y = (double)w(i); | |
- h = (ENDORSE(s)) * g; | |
+ h = ((s)) * g; | |
g = c * g; | |
- z = ENDORSE(PYTHAG(f, h)); | |
+ z = (PYTHAG(f, h)); | |
rv1[j] = z; | |
c = f / z; | |
s = h / z; | |
- f = x * c + g * (ENDORSE(s)); | |
- g = g * c - x * (ENDORSE(s)); | |
- h = y * (ENDORSE(s)); | |
+ f = x * c + g * ((s)); | |
+ g = g * c - x * ((s)); | |
+ h = y * ((s)); | |
y = y * c; | |
for (jj = 0; jj < n; jj++) | |
{ | |
x = (double)v(jj,j); | |
z = (double)v(jj,i); | |
- v(jj,j) = (float)(ENDORSE(x * c + z * s)); | |
- v(jj,i) = (float)(ENDORSE(z * c - x * s)); | |
+ v(jj,j) = (float)((x * c + z * s)); | |
+ v(jj,i) = (float)((z * c - x * s)); | |
} | |
- z = ENDORSE(PYTHAG(f, h)); | |
+ z = (PYTHAG(f, h)); | |
w(j) = (float)z; | |
if (z) | |
{ | |
@@ -304,14 +301,14 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
c = f * z; | |
s = h * z; | |
} | |
- f = (c * g) + ((ENDORSE(s)) * y); | |
- x = (c * y) - ((ENDORSE(s)) * g); | |
+ f = (c * g) + (((s)) * y); | |
+ x = (c * y) - (((s)) * g); | |
for (jj = 0; jj < m; jj++) | |
{ | |
y = (double)a(jj,j); | |
z = (double)a(jj,i); | |
- a(jj,j) = (float)(ENDORSE(y * c + z * s)); | |
- a(jj,i) = (float)(ENDORSE(z * c - y * s)); | |
+ a(jj,j) = (float)((y * c + z * s)); | |
+ a(jj,i) = (float)((z * c - y * s)); | |
} | |
} | |
rv1[l] = 0.0; | |
@@ -321,6 +318,5 @@ int svd(F2D *input, F2D *sOut, F2D *vOut) | |
} | |
free((void*) rv1); | |
- accept_roi_end(); | |
return(1); | |
} | |
diff --git a/svd3/svd2.c b/svd3/svd2.c | |
index 235d7e0..3e9dd66 100644 | |
--- a/svd3/svd2.c | |
+++ b/svd3/svd2.c | |
@@ -4,7 +4,7 @@ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <math.h> | |
-#include <enerc.h> | |
+ | |
#define SIGN(a,b) ((b) > 0.0 ? fabs(a) : - fabs(a)) | |
@@ -40,10 +40,9 @@ float absa,absb; | |
V (not V transpose) is output as the matrix V[nCols][nCols]. | |
*/ | |
int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
- accept_roi_begin(); | |
int flag,i,its,j,jj,k,l,nm; | |
float anorm,c,scale, x, y, z, g, f, h; | |
- APPROX float s, *rv1; | |
+ float s, *rv1; | |
rv1 = malloc(sizeof(float)*nCols); | |
if(rv1 == NULL) { | |
@@ -54,7 +53,7 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
g = scale = anorm = 0.0; | |
for(i=0;i<nCols;i++) { | |
l = i+1; | |
- rv1[i] = ENDORSE(scale*g); | |
+ rv1[i] = (scale*g); | |
s = g = scale = 0.0; | |
if(i < nRows) { | |
for(k=i;k<nRows;k++) scale += fabs(a[k][i]); | |
@@ -65,14 +64,14 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
} | |
f = a[i][i]; | |
// adapting code | |
- float temp = ENDORSE(s); | |
+ float temp = (s); | |
g = -SIGN(sqrt(temp),f); | |
//until here | |
- h = ENDORSE(f * g - s); | |
+ h = (f * g - s); | |
a[i][i] = f - g; | |
for(j=l;j<nCols;j++) { | |
for(s=0.0,k=i;k<nRows;k++) s += a[k][i] * a[k][j]; | |
- f = ENDORSE(s / h); | |
+ f = (s / h); | |
for(k=i;k<nRows;k++) a[k][j] += f * a[k][i]; | |
} | |
for(k=i;k<nRows;k++) a[k][i] *= scale; | |
@@ -89,20 +88,20 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
} | |
f = a[i][l]; | |
//adapting code | |
- float temp = ENDORSE(s); | |
+ float temp = (s); | |
g = - SIGN(sqrt(temp),f); | |
- h = ENDORSE(f * g - s); | |
+ h = (f * g - s); | |
a[i][l] = f - g; | |
for(k=l;k<nCols;k++) rv1[k] = a[i][k] / h; | |
for(j=l;j<nRows;j++) { | |
for(s=0.0,k=l;k<nCols;k++) s += a[j][k] * a[i][k]; | |
- for(k=l;k<nCols;k++) a[j][k] += ENDORSE(s * rv1[k]); | |
+ for(k=l;k<nCols;k++) a[j][k] += (s * rv1[k]); | |
} | |
for(k=l;k<nCols;k++) a[i][k] *= scale; | |
} | |
} | |
//ADAPTING CODE | |
- float temp = ENDORSE(rv1[i]); | |
+ float temp = (rv1[i]); | |
anorm = FMAX(anorm, (fabs(w[i]) + fabs(temp))); | |
} | |
@@ -113,13 +112,13 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
v[j][i] = (a[i][j] / a[i][l]) / g; | |
for(j=l;j<nCols;j++) { | |
for(s=0.0,k=l;k<nCols;k++) s += a[i][k] * v[k][j]; | |
- for(k=l;k<nCols;k++) v[k][j] += ENDORSE(s) * v[k][i]; | |
+ for(k=l;k<nCols;k++) v[k][j] += (s) * v[k][i]; | |
} | |
} | |
for(j=l;j<nCols;j++) v[i][j] = v[j][i] = 0.0; | |
} | |
v[i][i] = 1.0; | |
- g = ENDORSE(rv1[i]); | |
+ g = (rv1[i]); | |
l = i; | |
} | |
@@ -131,7 +130,7 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
g = 1.0 / g; | |
for(j=l;j<nCols;j++) { | |
for(s=0.0,k=l;k<nRows;k++) s += a[k][i] * a[k][j]; | |
- f = ENDORSE(s / a[i][i]) * g; | |
+ f = (s / a[i][i]) * g; | |
for(k=i;k<nRows;k++) a[k][j] += f * a[k][i]; | |
} | |
for(j=i;j<nRows;j++) a[j][i] *= g; | |
@@ -147,7 +146,7 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
for(l=k;l>=0;l--) { | |
nm = l-1; | |
//ADAPTING CODE | |
- float temp = ENDORSE(rv1[l]); | |
+ float temp = (rv1[l]); | |
if((fabs(temp) + anorm) == anorm) { | |
flag = 0; | |
break; | |
@@ -158,7 +157,7 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
c = 0.0; | |
s = 1.0; | |
for(i=l;i<=k;i++) { | |
- f = ENDORSE(s * rv1[i]); | |
+ f = (s * rv1[i]); | |
rv1[i] = c * rv1[i]; | |
if((fabs(f) + anorm) == anorm) break; | |
g = w[i]; | |
@@ -170,8 +169,8 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
for(j=0;j<nRows;j++) { | |
y = a[j][nm]; | |
z = a[j][i]; | |
- a[j][nm] = ENDORSE(y * c + z * s); | |
- a[j][i] = ENDORSE(z * c - y * s); | |
+ a[j][nm] = (y * c + z * s); | |
+ a[j][i] = (z * c - y * s); | |
} | |
} | |
} | |
@@ -187,31 +186,31 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
x = w[l]; | |
nm = k-1; | |
y = w[nm]; | |
- g = ENDORSE(rv1[nm]); | |
- h = ENDORSE(rv1[k]); | |
+ g = (rv1[nm]); | |
+ h = (rv1[k]); | |
f = ((y - z) * (y + z) + (g - h) * (g + h)) / (2.0 * h * y); | |
g = pythag(f,1.0); | |
f = ((x - z) * (x + z) + h * ((y / (f + SIGN(g,f))) - h)) / x; | |
s = c = 1.0; | |
for(j=l;j<=nm;j++) { | |
i = j+1; | |
- g = ENDORSE(rv1[i]); | |
+ g = (rv1[i]); | |
y = w[i]; | |
- h = ENDORSE(s * g); | |
+ h = (s * g); | |
g = c * g; | |
z = pythag(f,h); | |
rv1[j] = z; | |
c = f/z; | |
s = h/z; | |
- f = ENDORSE(x * c + g * s); | |
- g = ENDORSE(g * c - x * s); | |
- h = ENDORSE(y * s); | |
+ f = (x * c + g * s); | |
+ g = (g * c - x * s); | |
+ h = (y * s); | |
y *= c; | |
for(jj=0;jj<nCols;jj++) { | |
x = v[jj][j]; | |
z = v[jj][i]; | |
- v[jj][j] = ENDORSE(x * c + z * s); | |
- v[jj][i] = ENDORSE(z * c - x * s); | |
+ v[jj][j] = (x * c + z * s); | |
+ v[jj][i] = (z * c - x * s); | |
} | |
z = pythag(f,h); | |
w[j] = z; | |
@@ -220,13 +219,13 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
c = f * z; | |
s = h * z; | |
} | |
- f = ENDORSE(c * g + s * y); | |
- x = ENDORSE(c * y - s * g); | |
+ f = (c * g + s * y); | |
+ x = (c * y - s * g); | |
for(jj=0;jj < nRows;jj++) { | |
y = a[jj][j]; | |
z = a[jj][i]; | |
- a[jj][j] = ENDORSE(y * c + z * s); | |
- a[jj][i] = ENDORSE(z * c - y * s); | |
+ a[jj][j] = (y * c + z * s); | |
+ a[jj][i] = (z * c - y * s); | |
} | |
} | |
rv1[l] = 0.0; | |
@@ -235,7 +234,6 @@ int svd2(float **a, int nRows, int nCols, float *w, float **v) { | |
} | |
} | |
free(rv1); | |
- accept_roi_end(); | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment