summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/signalProcessing/transforms
diff options
context:
space:
mode:
authorSiddhu89902017-07-04 20:09:20 +0530
committerSiddhu89902017-07-04 20:09:20 +0530
commit9981dc71e9478fee921175d300d69fd5ba655dc5 (patch)
treeeb3170cb039ee25a34fb4812d90672af8c16b213 /2.3-1/src/c/signalProcessing/transforms
parent0de1d810a20afa0d8a76cecca8d651e7696a86b6 (diff)
parent87a33013355c6367ac01d88c3c945c3b2e8545f6 (diff)
downloadScilab2C-9981dc71e9478fee921175d300d69fd5ba655dc5.tar.gz
Scilab2C-9981dc71e9478fee921175d300d69fd5ba655dc5.tar.bz2
Scilab2C-9981dc71e9478fee921175d300d69fd5ba655dc5.zip
Merge branch 'ukashanoor-master'
Merged after removing bug for dct and idct
Diffstat (limited to '2.3-1/src/c/signalProcessing/transforms')
-rw-r--r--2.3-1/src/c/signalProcessing/transforms/dct/cdcta.c99
-rw-r--r--2.3-1/src/c/signalProcessing/transforms/dct/zdcta.c121
-rw-r--r--2.3-1/src/c/signalProcessing/transforms/idct/cidcta.c45
-rw-r--r--2.3-1/src/c/signalProcessing/transforms/idct/zidcta.c43
4 files changed, 228 insertions, 80 deletions
diff --git a/2.3-1/src/c/signalProcessing/transforms/dct/cdcta.c b/2.3-1/src/c/signalProcessing/transforms/dct/cdcta.c
index 5bc27929..7ff83645 100644
--- a/2.3-1/src/c/signalProcessing/transforms/dct/cdcta.c
+++ b/2.3-1/src/c/signalProcessing/transforms/dct/cdcta.c
@@ -15,6 +15,7 @@
#include "addition.h"
#include "types.h"
#include "floatComplex.h"
+#include "multiplication.h"
/*#include "matrixMultiplication"*/
/*#include <fftw3.h>*/
#include <math.h>
@@ -24,10 +25,10 @@ void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out)
int i,j,k,u,v;
int n;
int x,y;
- float res,ress;
+ float res,ress,vv,ff;
float re,z,q,m;
- floatComplex accu = DoubleComplex(0, 0);
- floatComplex temp,mm;
+ floatComplex accu = FloatComplex(0, 0);
+ floatComplex temp,mm,aa,bb,cc;
if(sign==-1)
{
if(row==1)
@@ -43,17 +44,25 @@ void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out)
{
for(j=0;j<col;j++)
{
- y=row*j+i;
- temp=in[y]*(cos(((M_PI)*(y+1-1./2.)*(x))/n));
+ y=row*j+i;
+ vv = cos(((M_PI)*(y+1-1./2.)*(x))/n);
+ aa = FloatComplex(vv,0);
+ temp=cmuls(in[y],aa);
out[x]=cadds(out[x],temp);
}
}
if(x==0)
- out[x]*=1./(sqrt(n));
+ {
+ vv = 1./(sqrt(n));
+ aa = FloatComplex(vv,0);
+ out[x]=cmuls(out[x],aa);
+ }
else
{
float res=2./n;
- out[x]*=sqrt(res);
+ res = sqrt(res);
+ aa = FloatComplex(res,0);
+ out[x]=cmuls(out[x],aa);
}
}
}
@@ -76,29 +85,53 @@ void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out)
y=j*row+i;
z=(float)(((float)j+1.0/2.0)*(float)v);
q=(float)(M_PI/(float)col);
- mm=in[y]*(cos(q*z));
+ vv = cos(q*z);
+ aa = FloatComplex(vv,0);
+ mm=cmuls(in[y],aa);
temp=cadds(temp,mm);
}
z=(float)(((float)i+1.0/2.0)*(float)u);
q=(float)(M_PI/(float)row);
- temp*=cos(q*z);
+ ff = cos(q*z);
+ bb = FloatComplex(ff,0);
+ temp=cmuls(temp,bb);
out[x]=cadds(out[x],temp);
}
if(u==0)
{
- out[x]*=1./sqrt((float)row);
+ vv = 1./sqrt((float)row);
+ aa = FloatComplex(vv,0);
+ out[x]=cmuls(out[x],aa);
if(v==0)
- out[x]*=1./sqrt((float)col);
+ {
+ vv = 1./sqrt((float)col);
+ aa = FloatComplex(vv,0);
+ out[x]=cmuls(out[x],aa);
+ }
else
- out[x]*=sqrt(2./col);
+ {
+ vv = sqrt(2./col);
+ aa = FloatComplex(vv,0);
+ out[x]=cmuls(out[x],aa);
+ }
}
else
{
- out[x]*=sqrt(2./row);
+ vv = sqrt(2./row);
+ aa = FloatComplex(vv,0);
+ out[x]=cmuls(out[x],aa);
if(v==0)
- out[x]*=1./sqrt((float)col);
+ {
+ vv = 1./sqrt((float)col);
+ aa = FloatComplex(vv,0);
+ out[x]=cmuls(out[x],aa);
+ }
else
- out[x]*=sqrt(2./col);
+ {
+ vv = sqrt(2./col);
+ aa = FloatComplex(vv,0);
+ out[x]=cmuls(out[x],aa);
+ }
}
}
}
@@ -125,12 +158,14 @@ void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out)
if(y==0)
{
q=res*(cos(((M_PI)*(j)*(v+1./2.))/n));
- out[x]=cadds(out[x],in[y]*q);
+ aa = FloatComplex(q,0);
+ out[x]=cadds(out[x],cmuls(in[y],aa));
}
else
{
q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n));
- out[x]=cadds(out[x],in[y]*q);
+ aa = FloatComplex(q,0);
+ out[x]=cadds(out[x],cmuls(in[y],aa));
}
}
}
@@ -156,19 +191,37 @@ void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out)
y=row*j+i;
mm=in[j*row+i];
z=(float)(((float)v+1.0/2.0)*(float)j);
- q=(float)(M_PI/(float)col);
- mm=mm*(cos(q*z));
+ q=(float)(M_PI/(float)col);
+ vv = cos(q*z);
+ aa = FloatComplex(vv,0);
+ mm=cmuls(mm,aa);
if(j==0)
- temp=cadds(temp,mm*(1./sqrt((float)col)));
+ {
+ vv = 1./sqrt((float)col);
+ aa = FloatComplex(vv,0);
+ temp=cadds(temp,cmuls(mm,aa));
+ }
else
- temp=cadds(temp,mm*sqrt(2./col));
+ {
+ vv = sqrt(2./col);
+ aa = FloatComplex(vv,0);
+ temp=cadds(temp,cmuls(mm,aa));
+ }
}
z=(float)(((float)u+1.0/2.0)*(float)i);
q=(float)(M_PI/(float)row);
if(i==0)
- out[x]=cadds(out[x],temp*((cos(z*q))*(1./sqrt(row))));
+ {
+ vv = (cos(z*q))*(1./sqrt(row));
+ aa = FloatComplex(vv,0);
+ out[x]=cadds(out[x],cmuls(temp,aa));
+ }
else
- out[x]=cadds(out[x],temp*((cos(z*q))*sqrt(2./row)));
+ {
+ vv = (cos(z*q))*sqrt(2./row);
+ aa = FloatComplex(vv,0);
+ out[x]=cadds(out[x],cmuls(temp,aa));
+ }
}
}
}
diff --git a/2.3-1/src/c/signalProcessing/transforms/dct/zdcta.c b/2.3-1/src/c/signalProcessing/transforms/dct/zdcta.c
index 0204d682..3ae2e333 100644
--- a/2.3-1/src/c/signalProcessing/transforms/dct/zdcta.c
+++ b/2.3-1/src/c/signalProcessing/transforms/dct/zdcta.c
@@ -15,6 +15,7 @@
#include "addition.h"
#include "types.h"
#include "doubleComplex.h"
+#include "multiplication.h"
/*#include "matrixMultiplication"*/
/*#include <fftw3.h>*/
#include <math.h>
@@ -24,10 +25,10 @@ void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out)
int i,j,k,u,v;
int n;
int x,y;
- double res,ress;
- double re,z,q,m;
+ double res,ress,vv,ff;
+ double re,z,q,m;
doubleComplex accu = DoubleComplex(0, 0);
- doubleComplex temp,mm;
+ doubleComplex temp,mm,aa,bb,cc;
if(sign==-1)
{
if(row==1)
@@ -43,22 +44,30 @@ void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out)
{
for(j=0;j<col;j++)
{
- y=row*j+i;
- temp=in[y]*(cos(((M_PI)*(y+1-1./2.)*(x))/n));
+ y=row*j+i;
+ vv = cos(((M_PI)*(y+1-1./2.)*(x))/n);
+ aa = DoubleComplex(vv,0);
+ temp=zmuls(in[y],aa);
out[x]=zadds(out[x],temp);
}
}
if(x==0)
- out[x]*=1./(sqrt(n));
+ {
+ vv = 1./(sqrt(n));
+ aa = DoubleComplex(vv,0);
+ out[x]=zmuls(out[x],aa);
+ }
else
{
- double res=2./n;
- out[x]*=sqrt(res);
+ double res=2./n;
+ res = sqrt(res);
+ aa = DoubleComplex(res,0);
+ out[x]=zmuls(out[x],aa);
}
}
}
- }
- else
+ }
+ else
{
n=col*row;
for(u=0;u<row;u++)
@@ -74,31 +83,55 @@ void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out)
for(j=0;j<col;j++)
{
y=j*row+i;
- z=(double)(((double)j+1.0/2.0)*(double)v);
- q=(double)(M_PI/(double)col);
- mm=in[y]*(cos(q*z));
+ z=(double )(((double )j+1.0/2.0)*(double )v);
+ q=(double )(M_PI/(double )col);
+ vv = cos(q*z);
+ aa = DoubleComplex(vv,0);
+ mm=zmuls(in[y],aa);
temp=zadds(temp,mm);
}
- z=(double)(((double)i+1.0/2.0)*(double)u);
- q=(double)(M_PI/(double)row);
- temp*=cos(q*z);
+ z=(double )(((double )i+1.0/2.0)*(double )u);
+ q=(double )(M_PI/(double )row);
+ ff = cos(q*z);
+ bb = DoubleComplex(ff,0);
+ temp=zmuls(temp,bb);
out[x]=zadds(out[x],temp);
- }
+ }
if(u==0)
{
- out[x]*=1./sqrt((double)row);
+ vv = 1./sqrt((double )row);
+ aa = DoubleComplex(vv,0);
+ out[x]=zmuls(out[x],aa);
if(v==0)
- out[x]*=1./sqrt((double)col);
+ {
+ vv = 1./sqrt((double )col);
+ aa = DoubleComplex(vv,0);
+ out[x]=zmuls(out[x],aa);
+ }
else
- out[x]*=sqrt(2./col);
+ {
+ vv = sqrt(2./col);
+ aa = DoubleComplex(vv,0);
+ out[x]=zmuls(out[x],aa);
+ }
}
else
{
- out[x]*=sqrt(2./row);
+ vv = sqrt(2./row);
+ aa = DoubleComplex(vv,0);
+ out[x]=zmuls(out[x],aa);
if(v==0)
- out[x]*=1./sqrt((double)col);
+ {
+ vv = 1./sqrt((double )col);
+ aa = DoubleComplex(vv,0);
+ out[x]=zmuls(out[x],aa);
+ }
else
- out[x]*=sqrt(2./col);
+ {
+ vv = sqrt(2./col);
+ aa = DoubleComplex(vv,0);
+ out[x]=zmuls(out[x],aa);
+ }
}
}
}
@@ -125,12 +158,14 @@ void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out)
if(y==0)
{
q=res*(cos(((M_PI)*(j)*(v+1./2.))/n));
- out[x]=zadds(out[x],in[y]*q);
+ aa = DoubleComplex(q,0);
+ out[x]=zadds(out[x],zmuls(in[y],aa));
}
else
{
q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n));
- out[x]=zadds(out[x],in[y]*q);
+ aa = DoubleComplex(q,0);
+ out[x]=zadds(out[x],zmuls(in[y],aa));
}
}
}
@@ -155,20 +190,38 @@ void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out)
{
y=row*j+i;
mm=in[j*row+i];
- z=(double)(((double)v+1.0/2.0)*(double)j);
- q=(double)(M_PI/(double)col);
- mm=mm*(cos(q*z));
+ z=(double )(((double )v+1.0/2.0)*(double )j);
+ q=(double )(M_PI/(double )col);
+ vv = cos(q*z);
+ aa = DoubleComplex(vv,0);
+ mm=zmuls(mm,aa);
if(j==0)
- temp=zadds(temp,mm*(1./sqrt((double)col)));
+ {
+ vv = 1./sqrt((double )col);
+ aa = DoubleComplex(vv,0);
+ temp=zadds(temp,zmuls(mm,aa));
+ }
else
- temp=zadds(temp,mm*sqrt(2./col));
+ {
+ vv = sqrt(2./col);
+ aa = DoubleComplex(vv,0);
+ temp=zadds(temp,zmuls(mm,aa));
+ }
}
- z=(double)(((double)u+1.0/2.0)*(double)i);
- q=(double)(M_PI/(double)row);
+ z=(double )(((double )u+1.0/2.0)*(double )i);
+ q=(double )(M_PI/(double )row);
if(i==0)
- out[x]=zadds(out[x],temp*((cos(z*q))*(1./sqrt(row))));
+ {
+ vv = (cos(z*q))*(1./sqrt(row));
+ aa = DoubleComplex(vv,0);
+ out[x]=zadds(out[x],zmuls(temp,aa));
+ }
else
- out[x]=zadds(out[x],temp*((cos(z*q))*sqrt(2./row)));
+ {
+ vv = (cos(z*q))*sqrt(2./row);
+ aa = DoubleComplex(vv,0);
+ out[x]=zadds(out[x],zmuls(temp,aa));
+ }
}
}
}
diff --git a/2.3-1/src/c/signalProcessing/transforms/idct/cidcta.c b/2.3-1/src/c/signalProcessing/transforms/idct/cidcta.c
index ec0df0c7..ae98ba19 100644
--- a/2.3-1/src/c/signalProcessing/transforms/idct/cidcta.c
+++ b/2.3-1/src/c/signalProcessing/transforms/idct/cidcta.c
@@ -14,7 +14,8 @@
#include "idct.h"
#include "addition.h"
#include "types.h"
-#include "floatComplex.h"
+#include "floatComplex.h"
+#include "multiplication.h"
/*#include "matrixMultiplication"*/
/*#include <fftw3.h>*/
#include <math.h>
@@ -24,10 +25,10 @@ void cidcta(floatComplex *in,int row,int col,floatComplex *out)
int i,j,k,u,v;
int n=col;
int x,y;
- float res,ress;
+ float res,ress,vv,ff;
float re,z,q,m;
- floatComplex accu = DoubleComplex(0, 0);
- floatComplex temp,mm;
+ floatComplex accu = FloatComplex(0, 0);
+ floatComplex temp,mm,aa,bb;
if(row==1)
{
res=1./sqrt(n);
@@ -46,12 +47,14 @@ void cidcta(floatComplex *in,int row,int col,floatComplex *out)
if(y==0)
{
q=res*(cos(((M_PI)*(j)*(v+1./2.))/n));
- out[x]=cadds(out[x],in[y]*q);
+ aa=FloatComplex(q,0);
+ out[x]=cadds(out[x],cmuls(in[y],aa));
}
else
{
q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n));
- out[x]=cadds(out[x],in[y]*q);
+ aa=FloatComplex(q,0);
+ out[x]=cadds(out[x],cmuls(in[y],aa));
}
}
}
@@ -77,19 +80,37 @@ void cidcta(floatComplex *in,int row,int col,floatComplex *out)
y=row*j+i;
mm=in[j*row+i];
z=(float)(((float)v+1.0/2.0)*(float)j);
- q=(float)(M_PI/(float)col);
- mm=mm*(cos(q*z));
+ q=(float)(M_PI/(float)col);
+ vv=cos(q*z);
+ aa=FloatComplex(vv,0);
+ mm=cmuls(mm,aa);
if(j==0)
- temp=cadds(temp,mm*(1./sqrt((float)col)));
+ {
+ vv=1./sqrt((float)col);
+ aa=FloatComplex(vv,0);
+ temp=cadds(temp,cmuls(mm,aa));
+ }
else
- temp=cadds(temp,mm*sqrt(2./col));
+ {
+ vv=sqrt(2./col);
+ aa=FloatComplex(vv,0);
+ temp=cadds(temp,cmuls(mm,aa));
+ }
}
z=(float)(((float)u+1.0/2.0)*(float)i);
q=(float)(M_PI/(float)row);
if(i==0)
- out[x]=cadds(out[x],temp*((cos(z*q))*(1./sqrt(row))));
+ {
+ vv=(cos(z*q))*(1./sqrt(row));
+ aa=FloatComplex(vv,0);
+ out[x]=cadds(out[x],cmuls(temp,aa));
+ }
else
- out[x]=cadds(out[x],temp*((cos(z*q))*sqrt(2./row)));
+ {
+ vv=(cos(z*q))*sqrt(2./row);
+ aa=FloatComplex(vv,0);
+ out[x]=cadds(out[x],cmuls(temp,aa));
+ }
}
}
}
diff --git a/2.3-1/src/c/signalProcessing/transforms/idct/zidcta.c b/2.3-1/src/c/signalProcessing/transforms/idct/zidcta.c
index 2177b18c..cc01c966 100644
--- a/2.3-1/src/c/signalProcessing/transforms/idct/zidcta.c
+++ b/2.3-1/src/c/signalProcessing/transforms/idct/zidcta.c
@@ -15,6 +15,7 @@
#include "addition.h"
#include "types.h"
#include "doubleComplex.h"
+#include "multiplication.h"
/*#include "matrixMultiplication"*/
/*#include <fftw3.h>*/
#include <math.h>
@@ -24,10 +25,10 @@ void zidcta(doubleComplex *in,int row,int col,doubleComplex *out)
int i,j,k,u,v;
int n=col;
int x,y;
- double res,ress;
+ double res,ress,vv,ff;
double re,z,q,m;
doubleComplex accu = DoubleComplex(0, 0);
- doubleComplex temp,mm;
+ doubleComplex temp,mm,aa,bb;
if(row==1)
{
res=1./sqrt(n);
@@ -46,17 +47,19 @@ void zidcta(doubleComplex *in,int row,int col,doubleComplex *out)
if(y==0)
{
q=res*(cos(((M_PI)*(j)*(v+1./2.))/n));
- out[x]=zadds(out[x],in[y]*q);
+ aa=DoubleComplex(q,0);
+ out[x]=zadds(out[x],zmuls(in[y],aa));
}
else
{
q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n));
- out[x]=zadds(out[x],in[y]*q);
+ aa=DoubleComplex(q,0);
+ out[x]=zadds(out[x],zmuls(in[y],aa));
}
}
}
}
-
+
}
}
else
@@ -77,19 +80,37 @@ void zidcta(doubleComplex *in,int row,int col,doubleComplex *out)
y=row*j+i;
mm=in[j*row+i];
z=(double)(((double)v+1.0/2.0)*(double)j);
- q=(double)(M_PI/(double)col);
- mm=mm*(cos(q*z));
+ q=(double)(M_PI/(double)col);
+ vv=cos(q*z);
+ aa=DoubleComplex(vv,0);
+ mm=zmuls(mm,aa);
if(j==0)
- temp=zadds(temp,mm*(1./sqrt((double)col)));
+ {
+ vv=1./sqrt((double)col);
+ aa=DoubleComplex(vv,0);
+ temp=zadds(temp,zmuls(mm,aa));
+ }
else
- temp=zadds(temp,mm*sqrt(2./col));
+ {
+ vv=sqrt(2./col);
+ aa=DoubleComplex(vv,0);
+ temp=zadds(temp,zmuls(mm,aa));
+ }
}
z=(double)(((double)u+1.0/2.0)*(double)i);
q=(double)(M_PI/(double)row);
if(i==0)
- out[x]=zadds(out[x],temp*((cos(z*q))*(1./sqrt(row))));
+ {
+ vv=(cos(z*q))*(1./sqrt(row));
+ aa=DoubleComplex(vv,0);
+ out[x]=zadds(out[x],zmuls(temp,aa));
+ }
else
- out[x]=zadds(out[x],temp*((cos(z*q))*sqrt(2./row)));
+ {
+ vv=(cos(z*q))*sqrt(2./row);
+ aa=DoubleComplex(vv,0);
+ out[x]=zadds(out[x],zmuls(temp,aa));
+ }
}
}
}