/********************************************************
* ██████╗ ██████╗████████╗██╗
* ██╔════╝ ██╔════╝╚══██╔══╝██║
* ██║ ███╗██║ ██║ ██║
* ██║ ██║██║ ██║ ██║
* ╚██████╔╝╚██████╗ ██║ ███████╗
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see .
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#include "../core/macro.h"
#include "mathfunc_ext.h"
#include "cmath"
void gctl::DTfilter(double **a,int m,int n,double A,double B,double Q,int sw)
{
int i,j;
for(i=0;i=A)
a[i][j]=Q;
break;
}
case 1:
{
if(a[i][j]<=A)
a[i][j]=Q;
break;
}
case 2:
{
if((a[i][j]<=A)||(a[i][j]>=B))
a[i][j]=Q;
break;
}
case 3:
{
if((a[i][j]>=A)&&(a[i][j]<=B))
a[i][j]=Q;
break;
}
}
}
}
}
void gctl::DTari(double **a,int m,int n,double A,int sw)
{
int i,j;
for(i=0;i=0;i--)
{ for(j=(n-1);j>=0;j--)
{ zr[i+np][j+nq]=zr[i][j]-pjg;
} }
//---------------------------------------------
// extending data
//---------------------------------------------
if(m>1)
{ for(i=np;i<(m+np);i++)
{ zr[i][n1-1]=(double)0;
for(j=0;j=mx;i--)
for(j=(n+nx-1);j>=nx;j--)
a[i][j]=a[i-mx][j-nx];
for(i=mx;i<(m+mx);i++)
{ for(j=0;ja[i][j])
MxMn[0]=a[i][j];
}
}
MxMn[2]=p/(double)(m*n+1e-40);
}
double gctl::int4p(double x,double d,double y1,double y2,double y3,double y4)
{ double z,t;
t=y1*x*(x-d)/(2*d*d)-y2*(x+d)*(x-d)/(d*d)+y3*(x+d)*x/(2*d*d);
z=y2*(x-d)*(x-2*d)/(2*d*d)-y3*x*(x-2*d)/(d*d)+y4*x*(x-d)/(2*d*d);
z=(z+t)/2;
return(z);
}
void gctl::intp(double **a,int m,int n,int mi,int ni)
{ int i,j,k; double d,x;
// mi=(int)(dx0/dx+.0001)
// ---number of inserted rows + 1
// ni=(int)(dy0/dy+.0001)
// ---number of inserted columns + 1
ext(a,m,n,1,1);
for(i=m+1;i>=0;i--)
for(j=n+1;j>=0;j--)
a[i*mi][j*ni]=a[i][j];
d=(double)ni; //(0, d, 2d, 3d,) are y_values knawn
for(i=0;i<=(m+1)*mi;i+=mi)
{ for(j=0;j<=(n-2)*ni;j+=ni)
{ for(k=1;k=k1)&&(k1!=0))
{ j=j-k1; k1=k1/2;
}
j=j+k1;
}
for(j=1;jxLt)||(ly>yLt))
{
ls+=1; lx-=1; ly+=1; continue;
}
for(j=0;j<=n;j++)
{
k1=(j+1)*j/2+1; k2=k1+j; kx=j; ky=0;
ks=0;
for(k=k1;k<=k2;k++)
{
if((kx>xLt)||(ky>yLt))
{
ks+=1; kx-=1; ky+=1; continue;
}
p=0.;
for(kk=0;kkxLt)||(ky>yLt))
{
ks+=1; kx-=1; ky+=1; continue;
}
p=0.;
for(kk=0;kkxLt)||(ky>yLt))
{ ks+=1; kx-=1; ky+=1; continue; }
s[k-1-ks]=pow(x,kx)*pow(y,ky);
kx=kx-1; ky=ky+1;
}
}
return;
}
/////////////////////////////////
void gctl::tran(double **a,int n)
{ int i,j; double t;
for(i=0;i=tol)
{
f=u[i][i];
g=-sqrt(s)*f/(fabs(f)+(double)1e-40);
h=f*g-s;
u[i][i]=f-g;
if(l=tol)
{
f=u[i][i+1];
g=-sqrt(s)*f/(fabs(f)+(double)1e-40);
h=f*g-s;
u[i][i+1]=f-g;
for(j=l;jx)
x=y;
}
//C
//C ACCUMULATION OF RIGHT-HAND TRANSFORMS (V)
//C
if((Index==1)||(Index==3))
{
v[n-1][n-1]=(double)1;
g=e[n-1];
for(i=n-2;i>=0;i--)
{
l=i+1;
if(g!=(double)0)
{
h=u[i][i+1]*g;
for(j=l;j=0;i--)
{
l=i+1; g=q[i];
if(l=0;k--)
{
label_380: /////////////C TEST F-SPLITTING
for(l=k;l>=0;l--)
{
if(fabs(e[l])<=eps)
goto label_440;
if(l==0)
continue;
if(fabs(q[l-1])<=eps)
goto label_410;
}
label_410: ///// CANCELLATION OF E(L), IF L .GT. 1
c=(double)0;
s=(double)1;
for(i=l;i<=k;i++)
{
f=s*e[i]; e[i]*=c;
if(fabs(f)<=eps)
goto label_440;
g=q[i]; q[i]=sqrt(f*f+g*g);
h=q[i]; c=g/h; s=-f/h;
if((Index==1)||(Index==2))
{
for(j=0;j