Added absolute_import

pep c_functions.c
master
Per A Brodtkorb 9 years ago
parent 0fd326937f
commit cd7b75b184

@ -1,7 +1,6 @@
""" """
Covariance package in WAFO Toolbox. Covariance package in WAFO Toolbox.
""" """
from __future__ import absolute_import
from core import * # CovData1D from .core import * # CovData1D
#import models from . import estimation
import estimation

@ -1,3 +1,3 @@
from __future__ import absolute_import
from info import __doc__ from .info import __doc__
from info import * from .info import *

@ -15,7 +15,7 @@
void findrfc(double *y1,double hmin, int *ind, int n,int *info) { void findrfc(double *y1,double hmin, int *ind, int n,int *info) {
double xminus,xplus,Tpl,Tmi,*y,Tstart; double xminus,xplus,Tpl,Tmi,*y,Tstart;
int i,j,ix=0,NC,iy; int i,j,ix=0,NC;
info[0] = 0; info[0] = 0;
if (*(y1+0)> *(y1+1)){ if (*(y1+0)> *(y1+1)){
/* if first is a max , ignore the first max*/ /* if first is a max , ignore the first max*/
@ -35,7 +35,7 @@ void findrfc(double *y1,double hmin, int *ind, int n,int *info) {
if (( *(y+0) > *(y+1)) && ( *(y+1) > *(y+2)) ){ if (( *(y+0) > *(y+1)) && ( *(y+1) > *(y+2)) ){
info[0] = -1; info[0] = -1;
return; /*This is not a sequence of turningpoints, exit */ return; /*This is not a sequence of turningpoints, exit */
} }
if ((*(y+0) < *(y+1)) && (*(y+1)< *(y+2))){ if ((*(y+0) < *(y+1)) && (*(y+1)< *(y+2))){
@ -52,67 +52,65 @@ void findrfc(double *y1,double hmin, int *ind, int n,int *info) {
xplus=*(y+2*i+2); xplus=*(y+2*i+2);
if(i!=0){ if(i!=0){
j=i-1; j=i-1;
while((j>=0) && (*(y+2*j+1)<=*(y+2*i+1))){ while((j>=0) && (*(y+2*j+1)<=*(y+2*i+1))){
if( (*(y+2*j)<xminus) ){ if( (*(y+2*j)<xminus) ){
xminus=*(y+2*j); xminus=*(y+2*j);
Tmi=Tstart+2*j; Tmi=Tstart+2*j;
} /*if */ } /*if */
j--; j--;
} /*while j*/ } /*while j*/
} /*if i */ } /*if i */
if ( xminus >= xplus){ if ( xminus >= xplus){
if ( (*(y+2*i+1)-xminus) >= hmin){ if ( (*(y+2*i+1)-xminus) >= hmin){
*(ind+ix)=Tmi; *(ind+ix)=Tmi;
ix++; ix++;
*(ind+ix)=(Tstart+2*i+1); *(ind+ix)=(Tstart+2*i+1);
ix++; ix++;
} /*if*/ } /*if*/
goto L180; goto L180;
} }
j=i+1; j=i+1;
while((j<NC) ) { while((j<NC) ) {
if (*(y+2*j+1) >= *(y+2*i+1)) goto L170; if (*(y+2*j+1) >= *(y+2*i+1)) goto L170;
if( (*(y+2*j+2) <= xplus) ){ if( (*(y+2*j+2) <= xplus) ){
xplus=*(y+2*j+2); xplus=*(y+2*j+2);
Tpl=(Tstart+2*j+2); Tpl=(Tstart+2*j+2);
}/*if*/ }/*if*/
j++; j++;
} /*while*/ } /*while*/
if ( (*(y+2*i+1)-xminus) >= hmin) { if ( (*(y+2*i+1)-xminus) >= hmin) {
*(ind+ix)=Tmi; *(ind+ix)=Tmi;
ix++; ix++;
*(ind+ix)=(Tstart+2*i+1); *(ind+ix)=(Tstart+2*i+1);
ix++; ix++;
} /*if*/ } /*if*/
goto L180; goto L180;
L170: L170:
if (xplus <= xminus ) { if (xplus <= xminus ) {
if ( (*(y+2*i+1)-xminus) >= hmin){ if ( (*(y+2*i+1)-xminus) >= hmin){
*(ind+ix)=Tmi; *(ind+ix)=Tmi;
ix++; ix++;
*(ind+ix)=(Tstart+2*i+1); *(ind+ix)=(Tstart+2*i+1);
ix++; ix++;
} /*if*/ } /*if*/
/*goto L180;*/ /*goto L180;*/
} }
else{ else{
if ( (*(y+2*i+1)-xplus) >= hmin) { if ( (*(y+2*i+1)-xplus) >= hmin) {
*(ind+ix)=(Tstart+2*i+1); *(ind+ix)=(Tstart+2*i+1);
ix++; ix++;
*(ind+ix)=Tpl; *(ind+ix)=Tpl;
ix++; ix++;
} /*if*/ } /*if*/
} /*elseif*/ } /*elseif*/
L180: L180:
iy=i;
} /* for i */ } /* for i */
info[0] = ix; info[0] = ix;
return ; return ;
} }
@ -128,42 +126,42 @@ void findrfc(double *y1,double hmin, int *ind, int n,int *info) {
void findcross(double *y, double v, int *ind, int n, int *info) void findcross(double *y, double v, int *ind, int n, int *info)
{ int i,start, ix=0,dcross=0; { int i,start, ix=0,dcross=0;
start=0; start=0;
if ( y[0]< v){ if ( y[0]< v){
dcross=-1; /* first is a up-crossing*/ dcross=-1; /* first is a up-crossing*/
} }
else if ( y[0]> v){ else if ( y[0]> v){
dcross=1; /* first is a down-crossing*/ dcross=1; /* first is a down-crossing*/
} }
else if ( y[0]== v){ else if ( y[0]== v){
/* Find out what type of crossing we have next time.. */ /* Find out what type of crossing we have next time.. */
for (i=1; i<n; i++) { for (i=1; i<n; i++) {
start=i; start=i;
if ( y[i]< v){ if ( y[i]< v){
ind[ix] = i-1; /* first crossing is a down crossing*/ ind[ix] = i-1; /* first crossing is a down crossing*/
ix++; ix++;
dcross=-1; /* The next crossing is a up-crossing*/ dcross=-1; /* The next crossing is a up-crossing*/
goto L120; goto L120;
} }
else if ( y[i]> v){ else if ( y[i]> v){
ind[ix] = i-1; /* first crossing is a up-crossing*/ ind[ix] = i-1; /* first crossing is a up-crossing*/
ix++; ix++;
dcross=1; /*The next crossing is a down-crossing*/ dcross=1; /*The next crossing is a down-crossing*/
goto L120; goto L120;
} }
} }
} }
L120: L120:
for (i=start; i<n-1; i++) { for (i=start; i<n-1; i++) {
if (( (dcross==-1) && (y[i]<=v) && (y[i+1] > v) ) || ((dcross==1 ) && (y[i]>=v) && (y[i+1] < v) ) ) { if (( (dcross==-1) && (y[i]<=v) && (y[i+1] > v) ) || ((dcross==1 ) && (y[i]>=v) && (y[i+1] < v) ) ) {
ind[ix] = i; ind[ix] = i;
ix++; ix++;
dcross=-dcross; dcross=-dcross;
} }
} }
info[0] = ix; info[0] = ix;
return; return;
} }
@ -198,11 +196,11 @@ void findcross(double *y, double v, int *ind, int n, int *info)
*/ */
void disufq(double *rvec, double *ivec, void disufq(double *rvec, double *ivec,
double *rA, double *iA, double *rA, double *iA,
double *w, double *kw, double *w, double *kw,
double h, double g, double h, double g,
int nmin, int nmax, int nmin, int nmax,
int m, int n) int m, int n)
{ {
double Epij, Edij; double Epij, Edij;
double tmp1, tmp2, tmp3, tmp4, kfact; double tmp1, tmp2, tmp3, tmp4, kfact;
@ -229,62 +227,62 @@ void disufq(double *rvec, double *ivec,
kw1 = kw[ix]; kw1 = kw[ix];
Epij = kw1; Epij = kw1;
for (i=0;i<m;i++,ixi++,iz1++) { for (i=0;i<m;i++,ixi++,iz1++) {
rrA = rA[ixi]*rA[ixi]; /// rrA = rA[ixi]*rA[ixi]; ///
iiA = iA[ixi]*iA[ixi]; /// iiA = iA[ixi]*iA[ixi]; ///
riA = rA[ixi]*iA[ixi]; /// riA = rA[ixi]*iA[ixi]; ///
/// Sum frequency effects along the diagonal /// Sum frequency effects along the diagonal
tmp1 = kfact*(rrA-iiA)*Epij; tmp1 = kfact*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*riA*Epij; tmp2 = kfact*2.0*riA*Epij;
rvec[iz1] += tmp1; rvec[iz1] += tmp1;
ivec[iz1] += tmp2; ivec[iz1] += tmp2;
//rvec[iz2] += tmp1; //rvec[iz2] += tmp1;
//ivec[iz2] -= tmp2; //ivec[iz2] -= tmp2;
//iz2++; //iz2++;
/// Difference frequency effects are zero along the diagonal /// Difference frequency effects are zero along the diagonal
/// and are thus not contributing to the mean. /// and are thus not contributing to the mean.
} }
for (jy = ix+1;jy<nmax;jy++){ for (jy = ix+1;jy<nmax;jy++){
kw2 = kw[jy]; kw2 = kw[jy];
Epij = 0.5*(kw2 + kw1); Epij = 0.5*(kw2 + kw1);
Edij = -0.5*(kw2 - kw1); Edij = -0.5*(kw2 - kw1);
//printf("Edij = %f Epij = %f \n", Edij,Epij); //printf("Edij = %f Epij = %f \n", Edij,Epij);
ixi = ix*m; ixi = ix*m;
jyi = jy*m; jyi = jy*m;
iz1 = ixi+jyi; iz1 = ixi+jyi;
iv1 = jyi-ixi; iv1 = jyi-ixi;
//iz2 = (n*m-iz1); //iz2 = (n*m-iz1);
//iv2 = (n*m-iv1); //iv2 = (n*m-iv1);
for (i = 0;i<m;i++,ixi++,jyi++,iz1++,iv1++) { for (i = 0;i<m;i++,ixi++,jyi++,iz1++,iv1++) {
rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy]; rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy];
iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy]; iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy];
riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy]; riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy];
irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy]; irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy];
/* Sum frequency effects */ /* Sum frequency effects */
tmp1 = kfact*2.0*(rrA-iiA)*Epij; tmp1 = kfact*2.0*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*(riA+irA)*Epij; tmp2 = kfact*2.0*(riA+irA)*Epij;
rvec[iz1] += tmp1;///rvec[i][ix+jy] += tmp1; rvec[iz1] += tmp1;///rvec[i][ix+jy] += tmp1;
ivec[iz1] += tmp2;///ivec[i][ix+jy] += tmp2; ivec[iz1] += tmp2;///ivec[i][ix+jy] += tmp2;
//rvec[iz2] += tmp1;///rvec[i][n*m-(ix+jy)] += tmp1; //rvec[iz2] += tmp1;///rvec[i][n*m-(ix+jy)] += tmp1;
//ivec[iz2] -= tmp2;///ivec[i][n*m-(ix+jy)] -= tmp2; //ivec[iz2] -= tmp2;///ivec[i][n*m-(ix+jy)] -= tmp2;
// iz2++; // iz2++;
/* Difference frequency effects */ /* Difference frequency effects */
tmp1 = kfact*2.0*(rrA+iiA)*Edij; tmp1 = kfact*2.0*(rrA+iiA)*Edij;
tmp2 = kfact*2.0*(riA-irA)*Edij; tmp2 = kfact*2.0*(riA-irA)*Edij;
rvec[iv1] += tmp1;///rvec[i][jy-ix] += tmp1; rvec[iv1] += tmp1;///rvec[i][jy-ix] += tmp1;
ivec[iv1] += tmp2;///ivec[i][jy-ix] += tmp2; ivec[iv1] += tmp2;///ivec[i][jy-ix] += tmp2;
//rvec[iv2] += tmp1;///rvec[i][n*m-(jy-ix)] += tmp1; //rvec[iv2] += tmp1;///rvec[i][n*m-(jy-ix)] += tmp1;
//ivec[iv2] -= tmp2;///ivec[i][n*m-(jy-ix)] -= tmp2; //ivec[iv2] -= tmp2;///ivec[i][n*m-(jy-ix)] -= tmp2;
//iv2++; //iv2++;
} }
} }
} }
} }
@ -357,29 +355,29 @@ void disufq(double *rvec, double *ivec,
// iz2 = (n*m-iz1); // iz2 = (n*m-iz1);
// iv2 = n*m-iv1; // iv2 = n*m-iv1;
for (i=0;i<m;i++,ixi++,jyi++,iz1++,iv1++) { for (i=0;i<m;i++,ixi++,jyi++,iz1++,iv1++) {
rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy]; rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy];
iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy]; iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy];
riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy]; riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy];
irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy]; irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy];
/* Sum frequency effects */ /* Sum frequency effects */
tmp1 = kfact*2.0*(rrA-iiA)*Epij; tmp1 = kfact*2.0*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*(riA+irA)*Epij; tmp2 = kfact*2.0*(riA+irA)*Epij;
rvec[iz1] += tmp1;///rvec[i][jy+ix] += tmp1; rvec[iz1] += tmp1;///rvec[i][jy+ix] += tmp1;
ivec[iz1] += tmp2;///ivec[i][jy+ix] += tmp2; ivec[iz1] += tmp2;///ivec[i][jy+ix] += tmp2;
//rvec[iz2] += tmp1;///rvec[i][n*m-(jy+ix)] += tmp1; //rvec[iz2] += tmp1;///rvec[i][n*m-(jy+ix)] += tmp1;
//ivec[iz2] -= tmp2;///ivec[i][n*m-(jy+ix)] -= tmp2; //ivec[iz2] -= tmp2;///ivec[i][n*m-(jy+ix)] -= tmp2;
//iz2++; //iz2++;
/* Difference frequency effects */ /* Difference frequency effects */
tmp1 = kfact*2.0*(rrA+iiA)*Edij; tmp1 = kfact*2.0*(rrA+iiA)*Edij;
tmp2 = kfact*2.0*(riA-irA)*Edij; tmp2 = kfact*2.0*(riA-irA)*Edij;
rvec[iv1] += tmp1;///rvec[i][jy-ix] += tmp1; rvec[iv1] += tmp1;///rvec[i][jy-ix] += tmp1;
ivec[iv1] += tmp2;///ivec[i][jy-ix] -= tmp2; ivec[iv1] += tmp2;///ivec[i][jy-ix] -= tmp2;
//rvec[iv2] += tmp1; //rvec[iv2] += tmp1;
//ivec[iv2] -= tmp2; //ivec[iv2] -= tmp2;
//iv2++; //iv2++;
} }
} }
} }
@ -420,12 +418,12 @@ void disufq(double *rvec, double *ivec,
*/ */
void disufq2(double *rsvec, double *isvec, void disufq2(double *rsvec, double *isvec,
double *rdvec, double *idvec, double *rdvec, double *idvec,
double *rA, double *iA, double *rA, double *iA,
double *w, double *kw, double *w, double *kw,
double h, double g, double h, double g,
int nmin, int nmax, int nmin, int nmax,
int m, int n) int m, int n)
{ {
double Epij, Edij; double Epij, Edij;
double tmp1, tmp2, tmp3, tmp4, kfact; double tmp1, tmp2, tmp3, tmp4, kfact;
@ -455,62 +453,62 @@ void disufq2(double *rsvec, double *isvec,
kw1 = kw[ix]; kw1 = kw[ix];
Epij = kw1; Epij = kw1;
for (i=0;i<m;i++,ixi++,iz1++) { for (i=0;i<m;i++,ixi++,iz1++) {
rrA = rA[ixi]*rA[ixi]; /// rrA = rA[ixi]*rA[ixi]; ///
iiA = iA[ixi]*iA[ixi]; /// iiA = iA[ixi]*iA[ixi]; ///
riA = rA[ixi]*iA[ixi]; /// riA = rA[ixi]*iA[ixi]; ///
/// Sum frequency effects along the diagonal /// Sum frequency effects along the diagonal
tmp1 = kfact*(rrA-iiA)*Epij; tmp1 = kfact*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*riA*Epij; tmp2 = kfact*2.0*riA*Epij;
rsvec[iz1] += tmp1; rsvec[iz1] += tmp1;
isvec[iz1] += tmp2; isvec[iz1] += tmp2;
//rsvec[iz2] += tmp1; //rsvec[iz2] += tmp1;
//isvec[iz2] -= tmp2; //isvec[iz2] -= tmp2;
//iz2++; //iz2++;
/// Difference frequency effects are zero along the diagonal /// Difference frequency effects are zero along the diagonal
/// and are thus not contributing to the mean. /// and are thus not contributing to the mean.
} }
for (jy = ix+1;jy<nmax;jy++){ for (jy = ix+1;jy<nmax;jy++){
kw2 = kw[jy]; kw2 = kw[jy];
Epij = 0.5*(kw2 + kw1); Epij = 0.5*(kw2 + kw1);
Edij = -0.5*(kw2 - kw1); Edij = -0.5*(kw2 - kw1);
//printf("Edij = %f Epij = %f \n", Edij,Epij); //printf("Edij = %f Epij = %f \n", Edij,Epij);
ixi = ix*m; ixi = ix*m;
jyi = jy*m; jyi = jy*m;
iz1 = ixi+jyi; iz1 = ixi+jyi;
iv1 = jyi-ixi; iv1 = jyi-ixi;
//iz2 = (n*m-iz1); //iz2 = (n*m-iz1);
//iv2 = (n*m-iv1); //iv2 = (n*m-iv1);
for (i = 0;i<m;i++,ixi++,jyi++,iz1++,iv1++) { for (i = 0;i<m;i++,ixi++,jyi++,iz1++,iv1++) {
rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy]; rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy];
iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy]; iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy];
riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy]; riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy];
irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy]; irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy];
/* Sum frequency effects */ /* Sum frequency effects */
tmp1 = kfact*2.0*(rrA-iiA)*Epij; tmp1 = kfact*2.0*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*(riA+irA)*Epij; tmp2 = kfact*2.0*(riA+irA)*Epij;
rsvec[iz1] += tmp1; ///rvec[i][ix+jy] += tmp1; rsvec[iz1] += tmp1; ///rvec[i][ix+jy] += tmp1;
isvec[iz1] += tmp2; ///ivec[i][ix+jy] += tmp2; isvec[iz1] += tmp2; ///ivec[i][ix+jy] += tmp2;
//rsvec[iz2] += tmp1;///rvec[i][n*m-(ix+jy)] += tmp1; //rsvec[iz2] += tmp1;///rvec[i][n*m-(ix+jy)] += tmp1;
//isvec[iz2] -= tmp2;///ivec[i][n*m-(ix+jy)] += tmp2; //isvec[iz2] -= tmp2;///ivec[i][n*m-(ix+jy)] += tmp2;
//iz2++; //iz2++;
/* Difference frequency effects */ /* Difference frequency effects */
tmp1 = kfact*2.0*(rrA+iiA)*Edij; tmp1 = kfact*2.0*(rrA+iiA)*Edij;
tmp2 = kfact*2.0*(riA-irA)*Edij; tmp2 = kfact*2.0*(riA-irA)*Edij;
rdvec[iv1] += tmp1;///rvec[i][jy-ix] += tmp1; rdvec[iv1] += tmp1;///rvec[i][jy-ix] += tmp1;
idvec[iv1] += tmp2;///ivec[i][jy-ix] += tmp2; idvec[iv1] += tmp2;///ivec[i][jy-ix] += tmp2;
//rdvec[iv2] += tmp1;///rvec[i][n*m-(jy-ix)] += tmp1; //rdvec[iv2] += tmp1;///rvec[i][n*m-(jy-ix)] += tmp1;
//idvec[iv2] -= tmp2;///ivec[i][n*m-(jy-ix)] -= tmp2; //idvec[iv2] -= tmp2;///ivec[i][n*m-(jy-ix)] -= tmp2;
// iv2++; // iv2++;
} }
} }
} }
} }
@ -583,29 +581,29 @@ void disufq2(double *rsvec, double *isvec,
// iz2 = (n*m-iz1); // iz2 = (n*m-iz1);
// iv2 = (n*m-iv1); // iv2 = (n*m-iv1);
for (i=0;i<m;i++,ixi++,jyi++,iz1++,iv1++) { for (i=0;i<m;i++,ixi++,jyi++,iz1++,iv1++) {
rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy]; rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy];
iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy]; iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy];
riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy]; riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy];
irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy]; irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy];
/* Sum frequency effects */ /* Sum frequency effects */
tmp1 = kfact*2.0*(rrA-iiA)*Epij; tmp1 = kfact*2.0*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*(riA+irA)*Epij; tmp2 = kfact*2.0*(riA+irA)*Epij;
rsvec[iz1] += tmp1;///rsvec[i][jy+ix] += tmp1; rsvec[iz1] += tmp1;///rsvec[i][jy+ix] += tmp1;
isvec[iz1] += tmp2;///isvec[i][jy+ix] += tmp2; isvec[iz1] += tmp2;///isvec[i][jy+ix] += tmp2;
//rsvec[iz2] += tmp1;///rsvec[i][n*m-(jy+ix)] += tmp1; //rsvec[iz2] += tmp1;///rsvec[i][n*m-(jy+ix)] += tmp1;
//isvec[iz2] -= tmp2;///isvec[i][n*m-(jy-ix)] += tmp2; //isvec[iz2] -= tmp2;///isvec[i][n*m-(jy-ix)] += tmp2;
//iz2++; //iz2++;
/* Difference frequency effects */ /* Difference frequency effects */
tmp1 = kfact*2.0*(rrA+iiA)*Edij; tmp1 = kfact*2.0*(rrA+iiA)*Edij;
tmp2 = kfact*2.0*(riA-irA)*Edij; tmp2 = kfact*2.0*(riA-irA)*Edij;
rdvec[iv1] += tmp1; rdvec[iv1] += tmp1;
idvec[iv1] += tmp2; idvec[iv1] += tmp2;
//rdvec[iv2] += tmp1; //rdvec[iv2] += tmp1;
//idvec[iv2] -= tmp2; //idvec[iv2] -= tmp2;
// iv2++; // iv2++;
} }
} }
} }

@ -4,8 +4,7 @@ Spectrum package in WAFO Toolbox.
Readme - Readme file for module SPEC in WAFO Toolbox Readme - Readme file for module SPEC in WAFO Toolbox
""" """
from __future__ import absolute_import
from core import * from .core import *
#SpecData1D, SpecData2D, cltext from . import models
import models
from wafo.wave_theory import dispersion_relation from wafo.wave_theory import dispersion_relation

@ -340,7 +340,7 @@ from .core import *
from .distributions import * from .distributions import *
from . import estimation from . import estimation
#remove vonmises_cython from __all__, I don't know why it is included # remove vonmises_cython from __all__, I don't know why it is included
__all__ = [s for s in dir() if not (s.startswith('_') or s.endswith('cython'))] __all__ = [s for s in dir() if not (s.startswith('_') or s.endswith('cython'))]
from numpy.testing import Tester from numpy.testing import Tester

@ -2,6 +2,7 @@
Transform package in WAFO Toolbox. Transform package in WAFO Toolbox.
""" """
from __future__ import absolute_import
from .core import * from .core import *
from . import models from . import models
from . import estimation from . import estimation

@ -6,13 +6,13 @@ TrOchi
TrLinear TrLinear
''' '''
# !/usr/bin/env python # !/usr/bin/env python
from __future__ import division from __future__ import division, absolute_import
from scipy.optimize import brentq # @UnresolvedImport from scipy.optimize import brentq # @UnresolvedImport
from numpy import (sqrt, atleast_1d, abs, imag, sign, where, cos, arccos, ceil, from numpy import (sqrt, atleast_1d, abs, imag, sign, where, cos, arccos, ceil,
expm1, log1p, pi) expm1, log1p, pi)
import numpy as np import numpy as np
import warnings import warnings
from core import TrCommon, TrData from .core import TrCommon, TrData
__all__ = ['TrHermite', 'TrLinear', 'TrOchi'] __all__ = ['TrHermite', 'TrLinear', 'TrOchi']
_example = ''' _example = '''
@ -453,10 +453,11 @@ class TrOchi(TrCommon2):
# g1='[x(2)-2.*x(1).^2.*x(2).^2-P1, # g1='[x(2)-2.*x(1).^2.*x(2).^2-P1,
# 2.*x(1).*x(2).^2.*(3-8.*x(1).^2.*x(2))-P2 ]' # 2.*x(1).*x(2).^2.*(3-8.*x(1).^2.*x(2))-P2 ]'
# Or solve the following 1D non-linear equation for sig2^2: # Or solve the following 1D non-linear equation for sig2^2:
g2 = lambda x: -sqrt(abs(x - 1) * 2) * \ def g2(x):
(3. * x - 4 * abs(x - 1)) + abs(skew) return (-sqrt(abs(x - 1) * 2) * (3. * x - 4 * abs(x - 1)) +
abs(skew))
a1 = 1. # % Start interval where sig2^2 is located. a1 = 1. # Start interval where sig2^2 is located.
a2 = 2. a2 = 2.
sig22 = brentq(g2, a1, a2) # % smallest solution for sig22 sig22 = brentq(g2, a1, a2) # % smallest solution for sig22

Loading…
Cancel
Save