Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2563


Ignore:
Timestamp:
12/17/09 17:05:22 (14 years ago)
Author:
gkronber
Message:

Updated ALGLIB to latest version. #751 (Plugin for for data-modeling with ANN (integrated into CEDMA))

Location:
trunk/sources/ALGLIB
Files:
105 added
2 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/ALGLIB/ALGLIB.csproj

    r2445 r2563  
    8080  </ItemGroup>
    8181  <ItemGroup>
     82    <Compile Include="airyf.cs" />
    8283    <Compile Include="ap.cs" />
     84    <Compile Include="autogk.cs" />
     85    <Compile Include="bdss.cs" />
    8386    <Compile Include="bdsvd.cs" />
     87    <Compile Include="bessel.cs" />
     88    <Compile Include="betaf.cs" />
    8489    <Compile Include="bidiagonal.cs" />
     90    <Compile Include="binomialdistr.cs" />
    8591    <Compile Include="blas.cs" />
     92    <Compile Include="cblas.cs" />
     93    <Compile Include="cdet.cs" />
     94    <Compile Include="chebyshev.cs" />
     95    <Compile Include="chisquaredistr.cs" />
     96    <Compile Include="cholesky.cs" />
     97    <Compile Include="cinverse.cs" />
     98    <Compile Include="clu.cs" />
     99    <Compile Include="conv.cs" />
     100    <Compile Include="corr.cs" />
    86101    <Compile Include="correlation.cs" />
    87102    <Compile Include="AlglibPlugin.cs">
    88103      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    89104    </Compile>
     105    <Compile Include="correlationtests.cs" />
     106    <Compile Include="cqr.cs" />
     107    <Compile Include="crcond.cs" />
     108    <Compile Include="creflections.cs" />
     109    <Compile Include="csolve.cs" />
     110    <Compile Include="ctrinverse.cs" />
     111    <Compile Include="ctrlinsolve.cs" />
     112    <Compile Include="dawson.cs" />
     113    <Compile Include="densesolver.cs" />
    90114    <Compile Include="descriptivestatistics.cs" />
    91     <Compile Include="gammaf.cs" />
     115    <Compile Include="det.cs" />
     116    <Compile Include="dforest.cs" />
     117    <Compile Include="elliptic.cs" />
     118    <Compile Include="estnorm.cs" />
     119    <Compile Include="expintegrals.cs" />
     120    <Compile Include="fdistr.cs" />
     121    <Compile Include="fft.cs" />
     122    <Compile Include="fht.cs" />
     123    <Compile Include="fresnel.cs" />
     124    <Compile Include="ftbase.cs" />
     125    <Compile Include="gammafunc.cs" />
     126    <Compile Include="gkq.cs" />
     127    <Compile Include="gq.cs" />
     128    <Compile Include="hbisinv.cs" />
     129    <Compile Include="hblas.cs" />
     130    <Compile Include="hcholesky.cs" />
     131    <Compile Include="hermite.cs" />
     132    <Compile Include="hessenberg.cs" />
     133    <Compile Include="hevd.cs" />
     134    <Compile Include="hqrnd.cs" />
     135    <Compile Include="hsschur.cs" />
     136    <Compile Include="htridiagonal.cs" />
     137    <Compile Include="ibetaf.cs" />
    92138    <Compile Include="igammaf.cs" />
     139    <Compile Include="inv.cs" />
     140    <Compile Include="inverseupdate.cs" />
     141    <Compile Include="jacobianelliptic.cs" />
     142    <Compile Include="jarquebera.cs" />
     143    <Compile Include="kmeans.cs" />
     144    <Compile Include="laguerre.cs" />
     145    <Compile Include="lbfgs.cs" />
     146    <Compile Include="lda.cs" />
     147    <Compile Include="ldlt.cs" />
    93148    <Compile Include="leastsquares.cs" />
     149    <Compile Include="legendre.cs" />
    94150    <Compile Include="linreg.cs" />
     151    <Compile Include="logit.cs" />
    95152    <Compile Include="lq.cs" />
     153    <Compile Include="lsfit.cs" />
     154    <Compile Include="lu.cs" />
     155    <Compile Include="mannwhitneyu.cs" />
     156    <Compile Include="matgen.cs" />
     157    <Compile Include="minlm.cs" />
     158    <Compile Include="mlpbase.cs" />
     159    <Compile Include="mlpe.cs" />
     160    <Compile Include="mlptrain.cs" />
     161    <Compile Include="nearunityunit.cs" />
    96162    <Compile Include="normaldistr.cs" />
     163    <Compile Include="nsevd.cs" />
     164    <Compile Include="odesolver.cs" />
     165    <Compile Include="pca.cs" />
     166    <Compile Include="poissondistr.cs" />
     167    <Compile Include="polint.cs" />
    97168    <Compile Include="Properties\AssemblyInfo.cs" />
     169    <Compile Include="psif.cs" />
    98170    <Compile Include="qr.cs" />
     171    <Compile Include="ratint.cs" />
     172    <Compile Include="ratinterpolation.cs" />
     173    <Compile Include="rcond.cs" />
    99174    <Compile Include="reflections.cs" />
    100175    <Compile Include="rotations.cs" />
     176    <Compile Include="sbisinv.cs" />
     177    <Compile Include="sblas.cs" />
     178    <Compile Include="schur.cs" />
     179    <Compile Include="sdet.cs" />
     180    <Compile Include="sevd.cs" />
     181    <Compile Include="sinverse.cs" />
     182    <Compile Include="spddet.cs" />
     183    <Compile Include="spdgevd.cs" />
     184    <Compile Include="spdinverse.cs" />
     185    <Compile Include="spdrcond.cs" />
     186    <Compile Include="spdsolve.cs" />
     187    <Compile Include="spline1d.cs" />
     188    <Compile Include="spline2d.cs" />
    101189    <Compile Include="spline3.cs" />
     190    <Compile Include="srcond.cs" />
     191    <Compile Include="ssolve.cs" />
     192    <Compile Include="stest.cs" />
     193    <Compile Include="studenttdistr.cs" />
     194    <Compile Include="studentttests.cs" />
    102195    <Compile Include="svd.cs" />
     196    <Compile Include="taskgen.cs" />
     197    <Compile Include="tdbisinv.cs" />
     198    <Compile Include="tdevd.cs" />
     199    <Compile Include="tridiagonal.cs" />
     200    <Compile Include="trigintegrals.cs" />
     201    <Compile Include="trinverse.cs" />
     202    <Compile Include="trlinsolve.cs" />
     203    <Compile Include="tsort.cs" />
     204    <Compile Include="variancetests.cs" />
     205    <Compile Include="wsr.cs" />
     206    <Compile Include="xblas.cs" />
    103207  </ItemGroup>
    104208  <ItemGroup>
  • trunk/sources/ALGLIB/ap.cs

    r2430 r2563  
    4545        public static bool operator==(Complex lhs, Complex rhs)
    4646        {
    47             return (lhs.x==rhs.x) & (lhs.y==rhs.y);
     47            return ((double)lhs.x==(double)rhs.x) & ((double)lhs.y==(double)rhs.y);
    4848        }
    4949        public static bool operator!=(Complex lhs, Complex rhs)
    5050        {
    51             return (lhs.x!=rhs.x) | (lhs.y!=rhs.y);
     51            return ((double)lhs.x!=(double)rhs.x) | ((double)lhs.y!=(double)rhs.y);
    5252        }
    5353        public static Complex operator+(Complex lhs)
     
    9292            return result;
    9393        }
    94     }   
     94    public override int GetHashCode()
     95    {
     96      return x.GetHashCode() ^ y.GetHashCode();
     97    }
     98    public override bool Equals(object obj)
     99    {
     100      if( obj is byte)
     101        return Equals(new Complex((byte)obj));
     102      if( obj is sbyte)
     103        return Equals(new Complex((sbyte)obj));
     104      if( obj is short)
     105        return Equals(new Complex((short)obj));
     106      if( obj is ushort)
     107        return Equals(new Complex((ushort)obj));
     108      if( obj is int)
     109        return Equals(new Complex((int)obj));
     110      if( obj is uint)
     111        return Equals(new Complex((uint)obj));
     112      if( obj is long)
     113        return Equals(new Complex((long)obj));
     114      if( obj is ulong)
     115        return Equals(new Complex((ulong)obj));
     116      if( obj is float)
     117        return Equals(new Complex((float)obj));
     118      if( obj is double)
     119        return Equals(new Complex((double)obj));
     120      if( obj is decimal)
     121        return Equals(new Complex((double)(decimal)obj));
     122      return base.Equals(obj);
     123    }
     124  }   
    95125   
    96126  /********************************************************************
  • trunk/sources/ALGLIB/bdsvd.cs

    r2430 r2563  
    154154
    155155
    156         /*************************************************************************
    157         Obsolete 1-based subroutine. See RMatrixBDSVD for 0-based replacement.
    158 
    159         History:
    160             * 31 March, 2007.
    161                 changed MAXITR from 6 to 12.
    162 
    163           -- LAPACK routine (version 3.0) --
    164              Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
    165              Courant Institute, Argonne National Lab, and Rice University
    166              October 31, 1999.
    167         *************************************************************************/
    168156        public static bool bidiagonalsvddecomposition(ref double[] d,
    169157            double[] e,
     
    277265            if( n==1 )
    278266            {
    279                 if( d[1]<0 )
     267                if( (double)(d[1])<(double)(0) )
    280268                {
    281269                    d[1] = -d[1];
     
    384372            }
    385373            sminl = 0;
    386             if( tol>=0 )
     374            if( (double)(tol)>=(double)(0) )
    387375            {
    388376               
     
    391379                //
    392380                sminoa = Math.Abs(d[1]);
    393                 if( sminoa!=0 )
     381                if( (double)(sminoa)!=(double)(0) )
    394382                {
    395383                    mu = sminoa;
     
    398386                        mu = Math.Abs(d[i])*(mu/(mu+Math.Abs(e[i-1])));
    399387                        sminoa = Math.Min(sminoa, mu);
    400                         if( sminoa==0 )
     388                        if( (double)(sminoa)==(double)(0) )
    401389                        {
    402390                            break;
     
    453441                // Find diagonal block of matrix to work on
    454442                //
    455                 if( tol<0 & Math.Abs(d[m])<=thresh )
     443                if( (double)(tol)<(double)(0) & (double)(Math.Abs(d[m]))<=(double)(thresh) )
    456444                {
    457445                    d[m] = 0;
     
    465453                    abss = Math.Abs(d[ll]);
    466454                    abse = Math.Abs(e[ll]);
    467                     if( tol<0 & abss<=thresh )
     455                    if( (double)(tol)<(double)(0) & (double)(abss)<=(double)(thresh) )
    468456                    {
    469457                        d[ll] = 0;
    470458                    }
    471                     if( abse<=thresh )
     459                    if( (double)(abse)<=(double)(thresh) )
    472460                    {
    473461                        matrixsplitflag = true;
     
    606594                //
    607595                bchangedir = false;
    608                 if( idir==1 & Math.Abs(d[ll])<1.0E-3*Math.Abs(d[m]) )
     596                if( idir==1 & (double)(Math.Abs(d[ll]))<(double)(1.0E-3*Math.Abs(d[m])) )
    609597                {
    610598                    bchangedir = true;
    611599                }
    612                 if( idir==2 & Math.Abs(d[m])<1.0E-3*Math.Abs(d[ll]) )
     600                if( idir==2 & (double)(Math.Abs(d[m]))<(double)(1.0E-3*Math.Abs(d[ll])) )
    613601                {
    614602                    bchangedir = true;
     
    616604                if( ll!=oldll | m!=oldm | bchangedir )
    617605                {
    618                     if( Math.Abs(d[ll])>=Math.Abs(d[m]) )
     606                    if( (double)(Math.Abs(d[ll]))>=(double)(Math.Abs(d[m])) )
    619607                    {
    620608                       
     
    644632                    // First apply standard test to bottom of matrix
    645633                    //
    646                     if( Math.Abs(e[m-1])<=Math.Abs(tol)*Math.Abs(d[m]) | tol<0 & Math.Abs(e[m-1])<=thresh )
     634                    if( (double)(Math.Abs(e[m-1]))<=(double)(Math.Abs(tol)*Math.Abs(d[m])) | (double)(tol)<(double)(0) & (double)(Math.Abs(e[m-1]))<=(double)(thresh) )
    647635                    {
    648636                        e[m-1] = 0;
    649637                        continue;
    650638                    }
    651                     if( tol>=0 )
     639                    if( (double)(tol)>=(double)(0) )
    652640                    {
    653641                       
     
    661649                        for(lll=ll; lll<=m-1; lll++)
    662650                        {
    663                             if( Math.Abs(e[lll])<=tol*mu )
     651                            if( (double)(Math.Abs(e[lll]))<=(double)(tol*mu) )
    664652                            {
    665653                                e[lll] = 0;
     
    684672                    // First apply standard test to top of matrix
    685673                    //
    686                     if( Math.Abs(e[ll])<=Math.Abs(tol)*Math.Abs(d[ll]) | tol<0 & Math.Abs(e[ll])<=thresh )
     674                    if( (double)(Math.Abs(e[ll]))<=(double)(Math.Abs(tol)*Math.Abs(d[ll])) | (double)(tol)<(double)(0) & (double)(Math.Abs(e[ll]))<=(double)(thresh) )
    687675                    {
    688676                        e[ll] = 0;
    689677                        continue;
    690678                    }
    691                     if( tol>=0 )
     679                    if( (double)(tol)>=(double)(0) )
    692680                    {
    693681                       
     
    701689                        for(lll=m-1; lll>=ll; lll--)
    702690                        {
    703                             if( Math.Abs(e[lll])<=tol*mu )
     691                            if( (double)(Math.Abs(e[lll]))<=(double)(tol*mu) )
    704692                            {
    705693                                e[lll] = 0;
     
    724712                // accuracy, and if so set the shift to zero.
    725713                //
    726                 if( tol>=0 & n*tol*(sminl/smax)<=Math.Max(eps, 0.01*tol) )
     714                if( (double)(tol)>=(double)(0) & (double)(n*tol*(sminl/smax))<=(double)(Math.Max(eps, 0.01*tol)) )
    727715                {
    728716                   
     
    752740                    // Test if shift negligible, and if so set to zero
    753741                    //
    754                     if( sll>0 )
    755                     {
    756                         if( AP.Math.Sqr(shift/sll)<eps )
     742                    if( (double)(sll)>(double)(0) )
     743                    {
     744                        if( (double)(AP.Math.Sqr(shift/sll))<(double)(eps) )
    757745                        {
    758746                            shift = 0;
     
    769757                // If SHIFT = 0, do simplified QR iteration
    770758                //
    771                 if( shift==0 )
     759                if( (double)(shift)==(double)(0) )
    772760                {
    773761                    if( idir==1 )
     
    817805                        // Test convergence
    818806                        //
    819                         if( Math.Abs(e[m-1])<=thresh )
     807                        if( (double)(Math.Abs(e[m-1]))<=(double)(thresh) )
    820808                        {
    821809                            e[m-1] = 0;
     
    868856                        // Test convergence
    869857                        //
    870                         if( Math.Abs(e[ll])<=thresh )
     858                        if( (double)(Math.Abs(e[ll]))<=(double)(thresh) )
    871859                        {
    872860                            e[ll] = 0;
     
    935923                        // Test convergence
    936924                        //
    937                         if( Math.Abs(e[m-1])<=thresh )
     925                        if( (double)(Math.Abs(e[m-1]))<=(double)(thresh) )
    938926                        {
    939927                            e[m-1] = 0;
     
    979967                        // Test convergence
    980968                        //
    981                         if( Math.Abs(e[ll])<=thresh )
     969                        if( (double)(Math.Abs(e[ll]))<=(double)(thresh) )
    982970                        {
    983971                            e[ll] = 0;
     
    10131001            for(i=1; i<=n; i++)
    10141002            {
    1015                 if( d[i]<0 )
     1003                if( (double)(d[i])<(double)(0) )
    10161004                {
    10171005                    d[i] = -d[i];
     
    10441032                for(j=2; j<=n+1-i; j++)
    10451033                {
    1046                     if( d[j]<=smin )
     1034                    if( (double)(d[j])<=(double)(smin) )
    10471035                    {
    10481036                        isub = j;
     
    11171105            double result = 0;
    11181106
    1119             if( b>=0 )
     1107            if( (double)(b)>=(double)(0) )
    11201108            {
    11211109                result = Math.Abs(a);
     
    11501138            fhmn = Math.Min(fa, ha);
    11511139            fhmx = Math.Max(fa, ha);
    1152             if( fhmn==0 )
     1140            if( (double)(fhmn)==(double)(0) )
    11531141            {
    11541142                ssmin = 0;
    1155                 if( fhmx==0 )
     1143                if( (double)(fhmx)==(double)(0) )
    11561144                {
    11571145                    ssmax = ga;
     
    11641152            else
    11651153            {
    1166                 if( ga<fhmx )
     1154                if( (double)(ga)<(double)(fhmx) )
    11671155                {
    11681156                    aas = 1+fhmn/fhmx;
     
    11761164                {
    11771165                    au = fhmx/ga;
    1178                     if( au==0 )
     1166                    if( (double)(au)==(double)(0) )
    11791167                    {
    11801168                       
     
    12491237            //
    12501238            pmax = 1;
    1251             swp = ha>fa;
     1239            swp = (double)(ha)>(double)(fa);
    12521240            if( swp )
    12531241            {
     
    12661254            gt = g;
    12671255            ga = Math.Abs(gt);
    1268             if( ga==0 )
     1256            if( (double)(ga)==(double)(0) )
    12691257            {
    12701258               
     
    12821270            {
    12831271                gasmal = true;
    1284                 if( ga>fa )
     1272                if( (double)(ga)>(double)(fa) )
    12851273                {
    12861274                    pmax = 2;
    1287                     if( fa/ga<AP.Math.MachineEpsilon )
     1275                    if( (double)(fa/ga)<(double)(AP.Math.MachineEpsilon) )
    12881276                    {
    12891277                       
     
    12931281                        gasmal = false;
    12941282                        ssmax = ga;
    1295                         if( ha>1 )
     1283                        if( (double)(ha)>(double)(1) )
    12961284                        {
    12971285                            v = ga/ha;
     
    13161304                    //
    13171305                    d = fa-ha;
    1318                     if( d==fa )
     1306                    if( (double)(d)==(double)(fa) )
    13191307                    {
    13201308                        l = 1;
     
    13291317                    tt = t*t;
    13301318                    s = Math.Sqrt(tt+mm);
    1331                     if( l==0 )
     1319                    if( (double)(l)==(double)(0) )
    13321320                    {
    13331321                        r = Math.Abs(m);
     
    13401328                    ssmin = ha/a;
    13411329                    ssmax = fa*a;
    1342                     if( mm==0 )
     1330                    if( (double)(mm)==(double)(0) )
    13431331                    {
    13441332                       
     
    13461334                        // Note that M is very tiny
    13471335                        //
    1348                         if( l==0 )
     1336                        if( (double)(l)==(double)(0) )
    13491337                        {
    13501338                            t = extsignbdsqr(2, ft)*extsignbdsqr(1, gt);
  • trunk/sources/ALGLIB/bidiagonal.cs

    r2430 r2563  
    775775
    776776
    777         /*************************************************************************
    778         Obsolete 1-based subroutine.
    779         See RMatrixBD for 0-based replacement.
    780         *************************************************************************/
    781777        public static void tobidiagonal(ref double[,] a,
    782778            int m,
     
    938934
    939935
    940         /*************************************************************************
    941         Obsolete 1-based subroutine.
    942         See RMatrixBDUnpackQ for 0-based replacement.
    943         *************************************************************************/
    944936        public static void unpackqfrombidiagonal(ref double[,] qp,
    945937            int m,
     
    10201012
    10211013
    1022         /*************************************************************************
    1023         Obsolete 1-based subroutine.
    1024         See RMatrixBDMultiplyByQ for 0-based replacement.
    1025         *************************************************************************/
    10261014        public static void multiplybyqfrombidiagonal(ref double[,] qp,
    10271015            int m,
     
    11691157
    11701158
    1171         /*************************************************************************
    1172         Obsolete 1-based subroutine.
    1173         See RMatrixBDUnpackPT for 0-based replacement.
    1174         *************************************************************************/
    11751159        public static void unpackptfrombidiagonal(ref double[,] qp,
    11761160            int m,
     
    12511235
    12521236
    1253         /*************************************************************************
    1254         Obsolete 1-based subroutine.
    1255         See RMatrixBDMultiplyByP for 0-based replacement.
    1256         *************************************************************************/
    12571237        public static void multiplybypfrombidiagonal(ref double[,] qp,
    12581238            int m,
     
    14021382
    14031383
    1404         /*************************************************************************
    1405         Obsolete 1-based subroutine.
    1406         See RMatrixBDUnpackDiagonals for 0-based replacement.
    1407         *************************************************************************/
    14081384        public static void unpackdiagonalsfrombidiagonal(ref double[,] b,
    14091385            int m,
  • trunk/sources/ALGLIB/blas.cs

    r2430 r2563  
    5151            for(ix=i1; ix<=i2; ix++)
    5252            {
    53                 if( x[ix]!=0 )
     53                if( (double)(x[ix])!=(double)(0) )
    5454                {
    5555                    absxi = Math.Abs(x[ix]);
    56                     if( scl<absxi )
     56                    if( (double)(scl)<(double)(absxi) )
    5757                    {
    5858                        ssq = 1+ssq*AP.Math.Sqr(scl/absxi);
     
    8282            for(i=i1+1; i<=i2; i++)
    8383            {
    84                 if( Math.Abs(x[i])>Math.Abs(x[result]) )
     84                if( (double)(Math.Abs(x[i]))>(double)(Math.Abs(x[result])) )
    8585                {
    8686                    result = i;
     
    104104            for(i=i1+1; i<=i2; i++)
    105105            {
    106                 if( Math.Abs(x[i,j])>Math.Abs(x[result,j]) )
     106                if( (double)(Math.Abs(x[i,j]))>(double)(Math.Abs(x[result,j])) )
    107107                {
    108108                    result = i;
     
    126126            for(j=j1+1; j<=j2; j++)
    127127            {
    128                 if( Math.Abs(x[i,j])>Math.Abs(x[i,result]) )
     128                if( (double)(Math.Abs(x[i,j]))>(double)(Math.Abs(x[i,result])) )
    129129                {
    130130                    result = j;
     
    316316                // beta*y
    317317                //
    318                 if( beta==0 )
     318                if( (double)(beta)==(double)(0) )
    319319                {
    320320                    for(i=iy1; i<=iy2; i++)
     
    361361                // beta*y
    362362                //
    363                 if( beta==0 )
     363                if( (double)(beta)==(double)(0) )
    364364                {
    365365                    for(i=iy1; i<=iy2; i++)
     
    405405            w = Math.Max(xabs, yabs);
    406406            z = Math.Min(xabs, yabs);
    407             if( z==0 )
     407            if( (double)(z)==(double)(0) )
    408408            {
    409409                result = w;
     
    497497            // Prepare C
    498498            //
    499             if( beta==0 )
     499            if( (double)(beta)==(double)(0) )
    500500            {
    501501                for(i=ci1; i<=ci2; i++)
  • trunk/sources/ALGLIB/correlation.cs

    r2430 r2563  
    8888                s = s+t1*t2;
    8989            }
    90             if( xv==0 | yv==0 )
     90            if( (double)(xv)==(double)(0) | (double)(yv)==(double)(0) )
    9191            {
    9292                result = 0;
     
    174174                    {
    175175                        k = t/2;
    176                         if( r[k-1]>=r[t-1] )
     176                        if( (double)(r[k-1])>=(double)(r[t-1]) )
    177177                        {
    178178                            t = 1;
     
    213213                            if( k<i )
    214214                            {
    215                                 if( r[k]>r[k-1] )
     215                                if( (double)(r[k])>(double)(r[k-1]) )
    216216                                {
    217217                                    k = k+1;
    218218                                }
    219219                            }
    220                             if( r[t-1]>=r[k-1] )
     220                            if( (double)(r[t-1])>=(double)(r[k-1]) )
    221221                            {
    222222                                t = 0;
     
    248248                while( j<=n-1 )
    249249                {
    250                     if( r[j]!=r[i] )
     250                    if( (double)(r[j])!=(double)(r[i]) )
    251251                    {
    252252                        break;
  • trunk/sources/ALGLIB/descriptivestatistics.cs

    r2445 r2563  
    9090                v2 = AP.Math.Sqr(v2)/n;
    9191                variance = (v1-v2)/(n-1);
    92                 if( variance<0 )
     92                if( (double)(variance)<(double)(0) )
    9393                {
    9494                    variance = 0;
     
    100100            // Skewness and kurtosis
    101101            //
    102             if( stddev!=0 )
     102            if( (double)(stddev)!=(double)(0) )
    103103            {
    104104                for(i=0; i<=n-1; i++)
     
    226226                    // 1 or 2 elements in partition
    227227                    //
    228                     if( ir==l+1 & x[ir]<x[l] )
     228                    if( ir==l+1 & (double)(x[ir])<(double)(x[l]) )
    229229                    {
    230230                        tval = x[l];
     
    240240                    x[midp] = x[l+1];
    241241                    x[l+1] = tval;
    242                     if( x[l]>x[ir] )
     242                    if( (double)(x[l])>(double)(x[ir]) )
    243243                    {
    244244                        tval = x[l];
     
    246246                        x[ir] = tval;
    247247                    }
    248                     if( x[l+1]>x[ir] )
     248                    if( (double)(x[l+1])>(double)(x[ir]) )
    249249                    {
    250250                        tval = x[l+1];
     
    252252                        x[ir] = tval;
    253253                    }
    254                     if( x[l]>x[l+1] )
     254                    if( (double)(x[l])>(double)(x[l+1]) )
    255255                    {
    256256                        tval = x[l];
     
    267267                            i = i+1;
    268268                        }
    269                         while( x[i]<a );
     269                        while( (double)(x[i])<(double)(a) );
    270270                        do
    271271                        {
    272272                            j = j-1;
    273273                        }
    274                         while( x[j]>a );
     274                        while( (double)(x[j])>(double)(a) );
    275275                        if( j<i )
    276276                        {
     
    305305            for(i=k+1; i<=n-1; i++)
    306306            {
    307                 if( x[i]<a )
     307                if( (double)(x[i])<(double)(a) )
    308308                {
    309309                    a = x[i];
     
    339339
    340340            System.Diagnostics.Debug.Assert(n>1, "CalculatePercentile: N<=1!");
    341             System.Diagnostics.Debug.Assert(p>=0 & p<=1, "CalculatePercentile: incorrect P!");
     341            System.Diagnostics.Debug.Assert((double)(p)>=(double)(0) & (double)(p)<=(double)(1), "CalculatePercentile: incorrect P!");
    342342            internalstatheapsort(ref x, n);
    343             if( p==0 )
     343            if( (double)(p)==(double)(0) )
    344344            {
    345345                v = x[0];
    346346                return;
    347347            }
    348             if( p==1 )
     348            if( (double)(p)==(double)(1) )
    349349            {
    350350                v = x[n-1];
     
    378378                {
    379379                    k = t/2;
    380                     if( arr[k-1]>=arr[t-1] )
     380                    if( (double)(arr[k-1])>=(double)(arr[t-1]) )
    381381                    {
    382382                        t = 1;
     
    411411                        if( k<i )
    412412                        {
    413                             if( arr[k]>arr[k-1] )
     413                            if( (double)(arr[k])>(double)(arr[k-1]) )
    414414                            {
    415415                                k = k+1;
    416416                            }
    417417                        }
    418                         if( arr[t-1]>=arr[k-1] )
     418                        if( (double)(arr[t-1])>=(double)(arr[k-1]) )
    419419                        {
    420420                            t = 0;
  • trunk/sources/ALGLIB/igammaf.cs

    r2445 r2563  
    7373
    7474            igammaepsilon = 0.000000000000001;
    75             if( x<=0 | a<=0 )
     75            if( (double)(x)<=(double)(0) | (double)(a)<=(double)(0) )
    7676            {
    7777                result = 0;
    7878                return result;
    7979            }
    80             if( x>1 & x>a )
     80            if( (double)(x)>(double)(1) & (double)(x)>(double)(a) )
    8181            {
    8282                result = 1-incompletegammac(a, x);
    8383                return result;
    8484            }
    85             ax = a*Math.Log(x)-x-gammaf.lngamma(a, ref tmp);
    86             if( ax<-709.78271289338399 )
     85            ax = a*Math.Log(x)-x-gammafunc.lngamma(a, ref tmp);
     86            if( (double)(ax)<(double)(-709.78271289338399) )
    8787            {
    8888                result = 0;
     
    9999                ans = ans+c;
    100100            }
    101             while( c/ans>igammaepsilon );
     101            while( (double)(c/ans)>(double)(igammaepsilon) );
    102102            result = ans*ax/a;
    103103            return result;
     
    164164            igammabignumber = 4503599627370496.0;
    165165            igammabignumberinv = 2.22044604925031308085*0.0000000000000001;
    166             if( x<=0 | a<=0 )
     166            if( (double)(x)<=(double)(0) | (double)(a)<=(double)(0) )
    167167            {
    168168                result = 1;
    169169                return result;
    170170            }
    171             if( x<1 | x<a )
     171            if( (double)(x)<(double)(1) | (double)(x)<(double)(a) )
    172172            {
    173173                result = 1-incompletegamma(a, x);
    174174                return result;
    175175            }
    176             ax = a*Math.Log(x)-x-gammaf.lngamma(a, ref tmp);
    177             if( ax<-709.78271289338399 )
     176            ax = a*Math.Log(x)-x-gammafunc.lngamma(a, ref tmp);
     177            if( (double)(ax)<(double)(-709.78271289338399) )
    178178            {
    179179                result = 0;
     
    197197                pk = pkm1*z-pkm2*yc;
    198198                qk = qkm1*z-qkm2*yc;
    199                 if( qk!=0 )
     199                if( (double)(qk)!=(double)(0) )
    200200                {
    201201                    r = pk/qk;
     
    211211                qkm2 = qkm1;
    212212                qkm1 = qk;
    213                 if( Math.Abs(pk)>igammabignumber )
     213                if( (double)(Math.Abs(pk))>(double)(igammabignumber) )
    214214                {
    215215                    pkm2 = pkm2*igammabignumberinv;
     
    219219                }
    220220            }
    221             while( t>igammaepsilon );
     221            while( (double)(t)>(double)(igammaepsilon) );
    222222            result = ans*ax;
    223223            return result;
     
    290290            y = 1-d-normaldistr.invnormaldistribution(y0)*Math.Sqrt(d);
    291291            x = a*y*y*y;
    292             lgm = gammaf.lngamma(a, ref tmp);
     292            lgm = gammafunc.lngamma(a, ref tmp);
    293293            i = 0;
    294294            while( i<10 )
    295295            {
    296                 if( x>x0 | x<x1 )
     296                if( (double)(x)>(double)(x0) | (double)(x)<(double)(x1) )
    297297                {
    298298                    d = 0.0625;
     
    300300                }
    301301                y = incompletegammac(a, x);
    302                 if( y<yl | y>yh )
     302                if( (double)(y)<(double)(yl) | (double)(y)>(double)(yh) )
    303303                {
    304304                    d = 0.0625;
    305305                    break;
    306306                }
    307                 if( y<y0 )
     307                if( (double)(y)<(double)(y0) )
    308308                {
    309309                    x0 = x;
     
    316316                }
    317317                d = (a-1)*Math.Log(x)-x-lgm;
    318                 if( d<-709.78271289338399 )
     318                if( (double)(d)<(double)(-709.78271289338399) )
    319319                {
    320320                    d = 0.0625;
     
    323323                d = -Math.Exp(d);
    324324                d = (y-y0)/d;
    325                 if( Math.Abs(d/x)<igammaepsilon )
     325                if( (double)(Math.Abs(d/x))<(double)(igammaepsilon) )
    326326                {
    327327                    result = x;
     
    331331                i = i+1;
    332332            }
    333             if( x0==iinvgammabignumber )
    334             {
    335                 if( x<=0 )
     333            if( (double)(x0)==(double)(iinvgammabignumber) )
     334            {
     335                if( (double)(x)<=(double)(0) )
    336336                {
    337337                    x = 1;
    338338                }
    339                 while( x0==iinvgammabignumber )
     339                while( (double)(x0)==(double)(iinvgammabignumber) )
    340340                {
    341341                    x = (1+d)*x;
    342342                    y = incompletegammac(a, x);
    343                     if( y<y0 )
     343                    if( (double)(y)<(double)(y0) )
    344344                    {
    345345                        x0 = x;
     
    358358                y = incompletegammac(a, x);
    359359                lgm = (x0-x1)/(x1+x0);
    360                 if( Math.Abs(lgm)<dithresh )
     360                if( (double)(Math.Abs(lgm))<(double)(dithresh) )
    361361                {
    362362                    break;
    363363                }
    364364                lgm = (y-y0)/y0;
    365                 if( Math.Abs(lgm)<dithresh )
    366                 {
    367                     break;
    368                 }
    369                 if( x<=0.0 )
    370                 {
    371                     break;
    372                 }
    373                 if( y>=y0 )
     365                if( (double)(Math.Abs(lgm))<(double)(dithresh) )
     366                {
     367                    break;
     368                }
     369                if( (double)(x)<=(double)(0.0) )
     370                {
     371                    break;
     372                }
     373                if( (double)(y)>=(double)(y0) )
    374374                {
    375375                    x1 = x;
  • trunk/sources/ALGLIB/leastsquares.cs

    r2430 r2563  
    190190            // B2 := (d^(-1) * B2')'
    191191            //
    192             if( d[1]!=0 )
     192            if( (double)(d[1])!=(double)(0) )
    193193            {
    194194                for(i=1; i<=ni; i++)
    195195                {
    196                     if( d[i]>AP.Math.MachineEpsilon*10*Math.Sqrt(ni)*d[1] )
     196                    if( (double)(d[i])>(double)(AP.Math.MachineEpsilon*10*Math.Sqrt(ni)*d[1]) )
    197197                    {
    198198                        b2[1,i] = b2[1,i]/d[i];
     
    286286            d1 = AP.Math.Sqr(c)*pp+AP.Math.Sqr(s)*qq-2*s*c*pq;
    287287            d2 = AP.Math.Sqr(s)*pp+AP.Math.Sqr(c)*qq+2*s*c*pq;
    288             if( Math.Abs(d1)>Math.Abs(d2) )
     288            if( (double)(Math.Abs(d1))>(double)(Math.Abs(d2)) )
    289289            {
    290290                m = Math.Abs(d1);
     
    296296            t1 = c*b1-s*b2;
    297297            t2 = s*b1+c*b2;
    298             if( Math.Abs(d1)>m*AP.Math.MachineEpsilon*1000 )
     298            if( (double)(Math.Abs(d1))>(double)(m*AP.Math.MachineEpsilon*1000) )
    299299            {
    300300                t1 = t1/d1;
     
    304304                t1 = 0;
    305305            }
    306             if( Math.Abs(d2)>m*AP.Math.MachineEpsilon*1000 )
     306            if( (double)(Math.Abs(d2))>(double)(m*AP.Math.MachineEpsilon*1000) )
    307307            {
    308308                t2 = t2/d2;
     
    493493            for(i=1; i<=ni; i++)
    494494            {
    495                 if( d[i]>AP.Math.MachineEpsilon*10*Math.Sqrt(ni)*d[1] )
     495                if( (double)(d[i])>(double)(AP.Math.MachineEpsilon*10*Math.Sqrt(ni)*d[1]) )
    496496                {
    497497                    b2[1,i] = b2[1,i]/d[i];
     
    585585            for(i=1; i<=n-1; i++)
    586586            {
    587                 if( x[i]>maxx )
     587                if( (double)(x[i])>(double)(maxx) )
    588588                {
    589589                    maxx = x[i];
    590590                }
    591                 if( x[i]<minx )
     591                if( (double)(x[i])<(double)(minx) )
    592592                {
    593593                    minx = x[i];
    594594                }
    595595            }
    596             if( minx==maxx )
     596            if( (double)(minx)==(double)(maxx) )
    597597            {
    598598                minx = minx-0.5;
     
    869869            for(i=1; i<=ni; i++)
    870870            {
    871                 if( d[i]>AP.Math.MachineEpsilon*10*Math.Sqrt(ni)*d[1] )
     871                if( (double)(d[i])>(double)(AP.Math.MachineEpsilon*10*Math.Sqrt(ni)*d[1]) )
    872872                {
    873873                    b2[1,i] = b2[1,i]/d[i];
     
    11331133                    return result;
    11341134                }
    1135                 if( ws[1]==0 | ws[nc]<=AP.Math.MachineEpsilon*10*Math.Sqrt(nc)*ws[1] )
     1135                if( (double)(ws[1])==(double)(0) | (double)(ws[nc])<=(double)(AP.Math.MachineEpsilon*10*Math.Sqrt(nc)*ws[1]) )
    11361136                {
    11371137                    result = false;
     
    12151215            for(i=1; i<=reducedsize; i++)
    12161216            {
    1217                 if( ws[i]!=0 & ws[i]>AP.Math.MachineEpsilon*10*Math.Sqrt(nc)*ws[1] )
     1217                if( (double)(ws[i])!=(double)(0) & (double)(ws[i])>(double)(AP.Math.MachineEpsilon*10*Math.Sqrt(nc)*ws[1]) )
    12181218                {
    12191219                    tmp[i] = tmp[i]/ws[i];
  • trunk/sources/ALGLIB/linreg.cs

    r2445 r2563  
    232232                means[j] = mean;
    233233                sigmas[j] = Math.Sqrt(variance);
    234                 if( sigmas[j]==0 )
     234                if( (double)(sigmas[j])==(double)(0) )
    235235                {
    236236                    sigmas[j] = 1;
     
    357357                }
    358358                descriptivestatistics.calculatemoments(ref x, npoints, ref mean, ref variance, ref skewness, ref kurtosis);
    359                 if( Math.Abs(mean)>Math.Sqrt(variance) )
     359                if( (double)(Math.Abs(mean))>(double)(Math.Sqrt(variance)) )
    360360                {
    361361                   
     
    372372                    // variation is large, it is better to bring variance to 1
    373373                    //
    374                     if( variance==0 )
     374                    if( (double)(variance)==(double)(0) )
    375375                    {
    376376                        variance = 1;
     
    698698            for(i=0; i<=npoints-1; i++)
    699699            {
    700                 if( xy[i,nvars]!=0 )
     700                if( (double)(xy[i,nvars])!=(double)(0) )
    701701                {
    702702                    i1_ = (offs)-(0);
     
    806806
    807807
    808         /*************************************************************************
    809         Obsolete subroutine, use LRBuildS
    810 
    811           -- ALGLIB --
    812              Copyright 26.04.2008 by Bochkanov Sergey
    813 
    814         References:
    815         1. Numerical Recipes in C, "15.2 Fitting Data to a Straight Line"
    816         *************************************************************************/
    817808        public static void lrlines(ref double[,] xy,
    818809            ref double[] s,
     
    845836            for(i=0; i<=n-1; i++)
    846837            {
    847                 if( s[i]<=0 )
     838                if( (double)(s[i])<=(double)(0) )
    848839                {
    849840                    info = -2;
     
    875866            e1 = 0.5*(ss+sxx+t);
    876867            e2 = 0.5*(ss+sxx-t);
    877             if( Math.Min(e1, e2)<=1000*AP.Math.MachineEpsilon*Math.Max(e1, e2) )
     868            if( (double)(Math.Min(e1, e2))<=(double)(1000*AP.Math.MachineEpsilon*Math.Max(e1, e2)) )
    878869            {
    879870                info = -3;
     
    923914
    924915
    925         /*************************************************************************
    926         Obsolete subroutine, use LRBuild
    927 
    928           -- ALGLIB --
    929              Copyright 02.08.2008 by Bochkanov Sergey
    930         *************************************************************************/
    931916        public static void lrline(ref double[,] xy,
    932917            int n,
     
    1005990            for(i=0; i<=npoints-1; i++)
    1006991            {
    1007                 if( s[i]<=0 )
     992                if( (double)(s[i])<=(double)(0) )
    1008993                {
    1009994                    info = -2;
     
    10621047                return;
    10631048            }
    1064             if( sv[0]<=0 )
     1049            if( (double)(sv[0])<=(double)(0) )
    10651050            {
    10661051               
     
    10901075                return;
    10911076            }
    1092             if( sv[nvars-1]<=epstol*AP.Math.MachineEpsilon*sv[0] )
     1077            if( (double)(sv[nvars-1])<=(double)(epstol*AP.Math.MachineEpsilon*sv[0]) )
    10931078            {
    10941079               
     
    11031088                for(k=nvars; k>=1; k--)
    11041089                {
    1105                     if( sv[k-1]>epstol*AP.Math.MachineEpsilon*sv[0] )
     1090                    if( (double)(sv[k-1])>(double)(epstol*AP.Math.MachineEpsilon*sv[0]) )
    11061091                    {
    11071092                       
     
    11731158            for(i=0; i<=nvars-1; i++)
    11741159            {
    1175                 if( sv[i]>epstol*AP.Math.MachineEpsilon*sv[0] )
     1160                if( (double)(sv[i])>(double)(epstol*AP.Math.MachineEpsilon*sv[0]) )
    11761161                {
    11771162                    svi[i] = 1/sv[i];
     
    12921277                ar.rmserror = ar.rmserror+AP.Math.Sqr(r-xy[i,nvars]);
    12931278                ar.avgerror = ar.avgerror+Math.Abs(r-xy[i,nvars]);
    1294                 if( xy[i,nvars]!=0 )
     1279                if( (double)(xy[i,nvars])!=(double)(0) )
    12951280                {
    12961281                    ar.avgrelerror = ar.avgrelerror+Math.Abs((r-xy[i,nvars])/xy[i,nvars]);
     
    13061291                    p += u[i,i_]*u[i,i_];
    13071292                }
    1308                 if( p>1-epstol*AP.Math.MachineEpsilon )
     1293                if( (double)(p)>(double)(1-epstol*AP.Math.MachineEpsilon) )
    13091294                {
    13101295                    ar.cvdefects[ar.ncvdefects] = i;
     
    13151300                ar.cvrmserror = ar.cvrmserror+AP.Math.Sqr(r-xy[i,nvars]);
    13161301                ar.cvavgerror = ar.cvavgerror+Math.Abs(r-xy[i,nvars]);
    1317                 if( xy[i,nvars]!=0 )
     1302                if( (double)(xy[i,nvars])!=(double)(0) )
    13181303                {
    13191304                    ar.cvavgrelerror = ar.cvavgrelerror+Math.Abs((r-xy[i,nvars])/xy[i,nvars]);
  • trunk/sources/ALGLIB/lq.cs

    r2430 r2563  
    247247
    248248
    249         /*************************************************************************
    250         Obsolete 1-based subroutine
    251         See RMatrixLQ for 0-based replacement.
    252         *************************************************************************/
    253249        public static void lqdecomposition(ref double[,] a,
    254250            int m,
     
    309305
    310306
    311         /*************************************************************************
    312         Obsolete 1-based subroutine
    313         See RMatrixLQUnpackQ for 0-based replacement.
    314         *************************************************************************/
    315307        public static void unpackqfromlq(ref double[,] a,
    316308            int m,
     
    380372
    381373
    382         /*************************************************************************
    383         Obsolete 1-based subroutine
    384         *************************************************************************/
    385374        public static void lqdecompositionunpacked(double[,] a,
    386375            int m,
  • trunk/sources/ALGLIB/normaldistr.cs

    r2445 r2563  
    6868            s = Math.Sign(x);
    6969            x = Math.Abs(x);
    70             if( x<0.5 )
     70            if( (double)(x)<(double)(0.5) )
    7171            {
    7272                xsq = x*x;
     
    8888                return result;
    8989            }
    90             if( x>=10 )
     90            if( (double)(x)>=(double)(10) )
    9191            {
    9292                result = s;
     
    131131            double q = 0;
    132132
    133             if( x<0 )
     133            if( (double)(x)<(double)(0) )
    134134            {
    135135                result = 2-erfc(-x);
    136136                return result;
    137137            }
    138             if( x<0.5 )
     138            if( (double)(x)<(double)(0.5) )
    139139            {
    140140                result = 1.0-erf(x);
    141141                return result;
    142142            }
    143             if( x>=10 )
     143            if( (double)(x)>=(double)(10) )
    144144            {
    145145                result = 0;
     
    269269            expm2 = 0.13533528323661269189;
    270270            s2pi = 2.50662827463100050242;
    271             if( y0<=0 )
     271            if( (double)(y0)<=(double)(0) )
    272272            {
    273273                result = -AP.Math.MaxRealNumber;
    274274                return result;
    275275            }
    276             if( y0>=1 )
     276            if( (double)(y0)>=(double)(1) )
    277277            {
    278278                result = AP.Math.MaxRealNumber;
     
    281281            code = 1;
    282282            y = y0;
    283             if( y>1.0-expm2 )
     283            if( (double)(y)>(double)(1.0-expm2) )
    284284            {
    285285                y = 1.0-y;
    286286                code = 0;
    287287            }
    288             if( y>expm2 )
     288            if( (double)(y)>(double)(expm2) )
    289289            {
    290290                y = y-0.5;
     
    312312            x0 = x-Math.Log(x)/x;
    313313            z = 1.0/x;
    314             if( x<8.0 )
     314            if( (double)(x)<(double)(8.0) )
    315315            {
    316316                p1 = 4.05544892305962419923;
  • trunk/sources/ALGLIB/qr.cs

    r2430 r2563  
    263263
    264264
    265         /*************************************************************************
    266         Obsolete 1-based subroutine. See RMatrixQR for 0-based replacement.
    267         *************************************************************************/
    268265        public static void qrdecomposition(ref double[,] a,
    269266            int m,
     
    322319
    323320
    324         /*************************************************************************
    325         Obsolete 1-based subroutine. See RMatrixQRUnpackQ for 0-based replacement.
    326         *************************************************************************/
    327321        public static void unpackqfromqr(ref double[,] a,
    328322            int m,
     
    392386
    393387
    394         /*************************************************************************
    395         Obsolete 1-based subroutine. See RMatrixQR for 0-based replacement.
    396         *************************************************************************/
    397388        public static void qrdecompositionunpacked(double[,] a,
    398389            int m,
  • trunk/sources/ALGLIB/reflections.cs

    r2430 r2563  
    9898            }
    9999            s = 1;
    100             if( mx!=0 )
    101             {
    102                 if( mx<=AP.Math.MinRealNumber/AP.Math.MachineEpsilon )
     100            if( (double)(mx)!=(double)(0) )
     101            {
     102                if( (double)(mx)<=(double)(AP.Math.MinRealNumber/AP.Math.MachineEpsilon) )
    103103                {
    104104                    s = AP.Math.MinRealNumber/AP.Math.MachineEpsilon;
     
    112112                else
    113113                {
    114                     if( mx>=AP.Math.MaxRealNumber*AP.Math.MachineEpsilon )
     114                    if( (double)(mx)>=(double)(AP.Math.MaxRealNumber*AP.Math.MachineEpsilon) )
    115115                    {
    116116                        s = AP.Math.MaxRealNumber*AP.Math.MachineEpsilon;
     
    130130            alpha = x[1];
    131131            xnorm = 0;
    132             if( mx!=0 )
     132            if( (double)(mx)!=(double)(0) )
    133133            {
    134134                for(j=2; j<=n; j++)
     
    138138                xnorm = Math.Sqrt(xnorm)*mx;
    139139            }
    140             if( xnorm==0 )
     140            if( (double)(xnorm)==(double)(0) )
    141141            {
    142142               
     
    154154            mx = Math.Max(Math.Abs(alpha), Math.Abs(xnorm));
    155155            beta = -(mx*Math.Sqrt(AP.Math.Sqr(alpha/mx)+AP.Math.Sqr(xnorm/mx)));
    156             if( alpha<0 )
     156            if( (double)(alpha)<(double)(0) )
    157157            {
    158158                beta = -beta;
     
    215215            int i_ = 0;
    216216
    217             if( tau==0 | n1>n2 | m1>m2 )
     217            if( (double)(tau)==(double)(0) | n1>n2 | m1>m2 )
    218218            {
    219219                return;
     
    294294            int i1_ = 0;
    295295
    296             if( tau==0 | n1>n2 | m1>m2 )
     296            if( (double)(tau)==(double)(0) | n1>n2 | m1>m2 )
    297297            {
    298298                return;
  • trunk/sources/ALGLIB/rotations.cs

    r2430 r2563  
    9393                        ctemp = c[j-m1+1];
    9494                        stemp = s[j-m1+1];
    95                         if( ctemp!=1 | stemp!=0 )
     95                        if( (double)(ctemp)!=(double)(1) | (double)(stemp)!=(double)(0) )
    9696                        {
    9797                            jp1 = j+1;
     
    129129                        ctemp = c[j-m1+1];
    130130                        stemp = s[j-m1+1];
    131                         if( ctemp!=1 | stemp!=0 )
     131                        if( (double)(ctemp)!=(double)(1) | (double)(stemp)!=(double)(0) )
    132132                        {
    133133                            temp = a[j+1,n1];
     
    150150                        ctemp = c[j-m1+1];
    151151                        stemp = s[j-m1+1];
    152                         if( ctemp!=1 | stemp!=0 )
     152                        if( (double)(ctemp)!=(double)(1) | (double)(stemp)!=(double)(0) )
    153153                        {
    154154                            jp1 = j+1;
     
    186186                        ctemp = c[j-m1+1];
    187187                        stemp = s[j-m1+1];
    188                         if( ctemp!=1 | stemp!=0 )
     188                        if( (double)(ctemp)!=(double)(1) | (double)(stemp)!=(double)(0) )
    189189                        {
    190190                            temp = a[j+1,n1];
     
    256256                        ctemp = c[j-n1+1];
    257257                        stemp = s[j-n1+1];
    258                         if( ctemp!=1 | stemp!=0 )
     258                        if( (double)(ctemp)!=(double)(1) | (double)(stemp)!=(double)(0) )
    259259                        {
    260260                            jp1 = j+1;
     
    292292                        ctemp = c[j-n1+1];
    293293                        stemp = s[j-n1+1];
    294                         if( ctemp!=1 | stemp!=0 )
     294                        if( (double)(ctemp)!=(double)(1) | (double)(stemp)!=(double)(0) )
    295295                        {
    296296                            temp = a[m1,j+1];
     
    313313                        ctemp = c[j-n1+1];
    314314                        stemp = s[j-n1+1];
    315                         if( ctemp!=1 | stemp!=0 )
     315                        if( (double)(ctemp)!=(double)(1) | (double)(stemp)!=(double)(0) )
    316316                        {
    317317                            jp1 = j+1;
     
    349349                        ctemp = c[j-n1+1];
    350350                        stemp = s[j-n1+1];
    351                         if( ctemp!=1 | stemp!=0 )
     351                        if( (double)(ctemp)!=(double)(1) | (double)(stemp)!=(double)(0) )
    352352                        {
    353353                            temp = a[m1,j+1];
     
    378378            double g1 = 0;
    379379
    380             if( g==0 )
     380            if( (double)(g)==(double)(0) )
    381381            {
    382382                cs = 1;
     
    386386            else
    387387            {
    388                 if( f==0 )
     388                if( (double)(f)==(double)(0) )
    389389                {
    390390                    cs = 0;
     
    399399                    cs = f1/r;
    400400                    sn = g1/r;
    401                     if( Math.Abs(f)>Math.Abs(g) & cs<0 )
     401                    if( (double)(Math.Abs(f))>(double)(Math.Abs(g)) & (double)(cs)<(double)(0) )
    402402                    {
    403403                        cs = -cs;
     
    408408            }
    409409        }
    410 
    411 
    412         private static void testrotations()
    413         {
    414             double[,] al1 = new double[0,0];
    415             double[,] al2 = new double[0,0];
    416             double[,] ar1 = new double[0,0];
    417             double[,] ar2 = new double[0,0];
    418             double[] cl = new double[0];
    419             double[] sl = new double[0];
    420             double[] cr = new double[0];
    421             double[] sr = new double[0];
    422             double[] w = new double[0];
    423             int m = 0;
    424             int n = 0;
    425             int maxmn = 0;
    426             double t = 0;
    427             int pass = 0;
    428             int passcount = 0;
    429             int i = 0;
    430             int j = 0;
    431             double err = 0;
    432             double maxerr = 0;
    433             bool isforward = new bool();
    434 
    435             passcount = 1000;
    436             maxerr = 0;
    437             for(pass=1; pass<=passcount; pass++)
    438             {
    439                
    440                 //
    441                 // settings
    442                 //
    443                 m = 2+AP.Math.RandomInteger(50);
    444                 n = 2+AP.Math.RandomInteger(50);
    445                 isforward = AP.Math.RandomReal()>0.5;
    446                 maxmn = Math.Max(m, n);
    447                 al1 = new double[m+1, n+1];
    448                 al2 = new double[m+1, n+1];
    449                 ar1 = new double[m+1, n+1];
    450                 ar2 = new double[m+1, n+1];
    451                 cl = new double[m-1+1];
    452                 sl = new double[m-1+1];
    453                 cr = new double[n-1+1];
    454                 sr = new double[n-1+1];
    455                 w = new double[maxmn+1];
    456                
    457                 //
    458                 // matrices and rotaions
    459                 //
    460                 for(i=1; i<=m; i++)
    461                 {
    462                     for(j=1; j<=n; j++)
    463                     {
    464                         al1[i,j] = 2*AP.Math.RandomReal()-1;
    465                         al2[i,j] = al1[i,j];
    466                         ar1[i,j] = al1[i,j];
    467                         ar2[i,j] = al1[i,j];
    468                     }
    469                 }
    470                 for(i=1; i<=m-1; i++)
    471                 {
    472                     t = 2*Math.PI*AP.Math.RandomReal();
    473                     cl[i] = Math.Cos(t);
    474                     sl[i] = Math.Sin(t);
    475                 }
    476                 for(j=1; j<=n-1; j++)
    477                 {
    478                     t = 2*Math.PI*AP.Math.RandomReal();
    479                     cr[j] = Math.Cos(t);
    480                     sr[j] = Math.Sin(t);
    481                 }
    482                
    483                 //
    484                 // Test left
    485                 //
    486                 applyrotationsfromtheleft(isforward, 1, m, 1, n, ref cl, ref sl, ref al1, ref w);
    487                 for(j=1; j<=n; j++)
    488                 {
    489                     applyrotationsfromtheleft(isforward, 1, m, j, j, ref cl, ref sl, ref al2, ref w);
    490                 }
    491                 err = 0;
    492                 for(i=1; i<=m; i++)
    493                 {
    494                     for(j=1; j<=n; j++)
    495                     {
    496                         err = Math.Max(err, Math.Abs(al1[i,j]-al2[i,j]));
    497                     }
    498                 }
    499                 maxerr = Math.Max(err, maxerr);
    500                
    501                 //
    502                 // Test right
    503                 //
    504                 applyrotationsfromtheright(isforward, 1, m, 1, n, ref cr, ref sr, ref ar1, ref w);
    505                 for(i=1; i<=m; i++)
    506                 {
    507                     applyrotationsfromtheright(isforward, i, i, 1, n, ref cr, ref sr, ref ar2, ref w);
    508                 }
    509                 err = 0;
    510                 for(i=1; i<=m; i++)
    511                 {
    512                     for(j=1; j<=n; j++)
    513                     {
    514                         err = Math.Max(err, Math.Abs(ar1[i,j]-ar2[i,j]));
    515                     }
    516                 }
    517                 maxerr = Math.Max(err, maxerr);
    518             }
    519             System.Console.Write("TESTING ROTATIONS");
    520             System.Console.WriteLine();
    521             System.Console.Write("Pass count ");
    522             System.Console.Write("{0,0:d}",passcount);
    523             System.Console.WriteLine();
    524             System.Console.Write("Error is ");
    525             System.Console.Write("{0,5:E3}",maxerr);
    526             System.Console.WriteLine();
    527         }
    528410    }
    529411}
  • trunk/sources/ALGLIB/spline3.cs

    r2430 r2563  
    2525    public class spline3
    2626    {
    27         /*************************************************************************
    28         This subroutine builds linear spline coefficients table.
    29 
    30         Input parameters:
    31             X   -   spline nodes, array[0..N-1]
    32             Y   -   function values, array[0..N-1]
    33             N   -   points count, N>=2
    34            
    35         Output parameters:
    36             C   -   coefficients table.  Used  by  SplineInterpolation  and  other
    37                     subroutines from this file.
    38 
    39           -- ALGLIB PROJECT --
    40              Copyright 24.06.2007 by Bochkanov Sergey
    41         *************************************************************************/
    4227        public static void buildlinearspline(double[] x,
    4328            double[] y,
     
    8671
    8772
    88         /*************************************************************************
    89         This subroutine builds cubic spline coefficients table.
    90 
    91         Input parameters:
    92             X           -   spline nodes, array[0..N-1]
    93             Y           -   function values, array[0..N-1]
    94             N           -   points count, N>=2
    95             BoundLType  -   boundary condition type for the left boundary
    96             BoundL      -   left boundary condition (first or second derivative,
    97                             depending on the BoundLType)
    98             BoundRType  -   boundary condition type for the right boundary
    99             BoundR      -   right boundary condition (first or second derivative,
    100                             depending on the BoundRType)
    101 
    102         Output parameters:
    103             C           -   coefficients table.  Used  by  SplineInterpolation and
    104                             other subroutines from this file.
    105                            
    106         The BoundLType/BoundRType parameters can have the following values:
    107             * 0,   which  corresponds  to  the  parabolically   terminated  spline
    108               (BoundL/BoundR are ignored).
    109             * 1, which corresponds to the first derivative boundary condition
    110             * 2, which corresponds to the second derivative boundary condition
    111 
    112           -- ALGLIB PROJECT --
    113              Copyright 23.06.2007 by Bochkanov Sergey
    114         *************************************************************************/
    11573        public static void buildcubicspline(double[] x,
    11674            double[] y,
     
    240198
    241199
    242         /*************************************************************************
    243         This subroutine builds cubic Hermite spline coefficients table.
    244 
    245         Input parameters:
    246             X           -   spline nodes, array[0..N-1]
    247             Y           -   function values, array[0..N-1]
    248             D           -   derivatives, array[0..N-1]
    249             N           -   points count, N>=2
    250 
    251         Output parameters:
    252             C           -   coefficients table.  Used  by  SplineInterpolation and
    253                             other subroutines from this file.
    254 
    255           -- ALGLIB PROJECT --
    256              Copyright 23.06.2007 by Bochkanov Sergey
    257         *************************************************************************/
    258200        public static void buildhermitespline(double[] x,
    259201            double[] y,
     
    310252
    311253
    312         /*************************************************************************
    313         This subroutine builds Akima spline coefficients table.
    314 
    315         Input parameters:
    316             X           -   spline nodes, array[0..N-1]
    317             Y           -   function values, array[0..N-1]
    318             N           -   points count, N>=5
    319 
    320         Output parameters:
    321             C           -   coefficients table.  Used  by  SplineInterpolation and
    322                             other subroutines from this file.
    323 
    324           -- ALGLIB PROJECT --
    325              Copyright 24.06.2007 by Bochkanov Sergey
    326         *************************************************************************/
    327254        public static void buildakimaspline(double[] x,
    328255            double[] y,
     
    365292            for(i=2; i<=n-3; i++)
    366293            {
    367                 if( Math.Abs(w[i-1])+Math.Abs(w[i+1])!=0 )
     294                if( (double)(Math.Abs(w[i-1])+Math.Abs(w[i+1]))!=(double)(0) )
    368295                {
    369296                    d[i] = (w[i+1]*diff[i-1]+w[i-1]*diff[i])/(w[i+1]+w[i-1]);
     
    386313
    387314
    388         /*************************************************************************
    389         This subroutine calculates the value of the spline at the given point X.
    390 
    391         Input parameters:
    392             C           -   coefficients table. Built by BuildLinearSpline,
    393                             BuildHermiteSpline, BuildCubicSpline, BuildAkimaSpline.
    394             X           -   point
    395 
    396         Result:
    397             S(x)
    398 
    399           -- ALGLIB PROJECT --
    400              Copyright 23.06.2007 by Bochkanov Sergey
    401         *************************************************************************/
    402315        public static double splineinterpolation(ref double[] c,
    403316            double x)
     
    420333            {
    421334                m = (l+r)/2;
    422                 if( c[m]>=x )
     335                if( (double)(c[m])>=(double)(x) )
    423336                {
    424337                    r = m;
     
    440353
    441354
    442         /*************************************************************************
    443         This subroutine differentiates the spline.
    444 
    445         Input parameters:
    446             C   -   coefficients table. Built by BuildLinearSpline,
    447                     BuildHermiteSpline, BuildCubicSpline, BuildAkimaSpline.
    448             X   -   point
    449 
    450         Result:
    451             S   -   S(x)
    452             DS  -   S'(x)
    453             D2S -   S''(x)
    454 
    455           -- ALGLIB PROJECT --
    456              Copyright 24.06.2007 by Bochkanov Sergey
    457         *************************************************************************/
    458355        public static void splinedifferentiation(ref double[] c,
    459356            double x,
     
    478375            {
    479376                m = (l+r)/2;
    480                 if( c[m]>=x )
     377                if( (double)(c[m])>=(double)(x) )
    481378                {
    482379                    r = m;
     
    499396
    500397
    501         /*************************************************************************
    502         This subroutine makes the copy of the spline.
    503 
    504         Input parameters:
    505             C   -   coefficients table. Built by BuildLinearSpline,
    506                     BuildHermiteSpline, BuildCubicSpline, BuildAkimaSpline.
    507 
    508         Result:
    509             CC  -   spline copy
    510 
    511           -- ALGLIB PROJECT --
    512              Copyright 29.06.2007 by Bochkanov Sergey
    513         *************************************************************************/
    514398        public static void splinecopy(ref double[] c,
    515399            ref double[] cc)
     
    527411
    528412
    529         /*************************************************************************
    530         This subroutine unpacks the spline into the coefficients table.
    531 
    532         Input parameters:
    533             C   -   coefficients table. Built by BuildLinearSpline,
    534                     BuildHermiteSpline, BuildCubicSpline, BuildAkimaSpline.
    535             X   -   point
    536 
    537         Result:
    538             Tbl -   coefficients table, unpacked format, array[0..N-2, 0..5].
    539                     For I = 0...N-2:
    540                         Tbl[I,0] = X[i]
    541                         Tbl[I,1] = X[i+1]
    542                         Tbl[I,2] = C0
    543                         Tbl[I,3] = C1
    544                         Tbl[I,4] = C2
    545                         Tbl[I,5] = C3
    546                     On [x[i], x[i+1]] spline is equals to:
    547                         S(x) = C0 + C1*t + C2*t^2 + C3*t^3
    548                         t = x-x[i]
    549 
    550           -- ALGLIB PROJECT --
    551              Copyright 29.06.2007 by Bochkanov Sergey
    552         *************************************************************************/
    553413        public static void splineunpack(ref double[] c,
    554414            ref int n,
     
    576436
    577437
    578         /*************************************************************************
    579         This subroutine performs linear transformation of the spline argument.
    580 
    581         Input parameters:
    582             C   -   coefficients table. Built by BuildLinearSpline,
    583                     BuildHermiteSpline, BuildCubicSpline, BuildAkimaSpline.
    584             A, B-   transformation coefficients: x = A*t + B
    585         Result:
    586             C   -   transformed spline
    587 
    588           -- ALGLIB PROJECT --
    589              Copyright 30.06.2007 by Bochkanov Sergey
    590         *************************************************************************/
    591438        public static void splinelintransx(ref double[] c,
    592439            double a,
     
    608455            // Special case: A=0
    609456            //
    610             if( a==0 )
     457            if( (double)(a)==(double)(0) )
    611458            {
    612459                v = splineinterpolation(ref c, b);
     
    641488
    642489
    643         /*************************************************************************
    644         This subroutine performs linear transformation of the spline.
    645 
    646         Input parameters:
    647             C   -   coefficients table. Built by BuildLinearSpline,
    648                     BuildHermiteSpline, BuildCubicSpline, BuildAkimaSpline.
    649             A, B-   transformation coefficients: S2(x) = A*S(x) + B
    650         Result:
    651             C   -   transformed spline
    652 
    653           -- ALGLIB PROJECT --
    654              Copyright 30.06.2007 by Bochkanov Sergey
    655         *************************************************************************/
    656490        public static void splinelintransy(ref double[] c,
    657491            double a,
     
    683517
    684518
    685         /*************************************************************************
    686         This subroutine integrates the spline.
    687 
    688         Input parameters:
    689             C   -   coefficients table. Built by BuildLinearSpline,
    690                     BuildHermiteSpline, BuildCubicSpline, BuildAkimaSpline.
    691             X   -   right bound of the integration interval [a, x]
    692         Result:
    693             integral(S(t)dt,a,x)
    694 
    695           -- ALGLIB PROJECT --
    696              Copyright 23.06.2007 by Bochkanov Sergey
    697         *************************************************************************/
    698519        public static double splineintegration(ref double[] c,
    699520            double x)
     
    718539            {
    719540                m = (l+r)/2;
    720                 if( c[m]>=x )
     541                if( (double)(c[m])>=(double)(x) )
    721542                {
    722543                    r = m;
     
    751572
    752573
    753         /*************************************************************************
    754         Obsolete subroutine, left for backward compatibility.
    755         *************************************************************************/
    756574        public static void spline3buildtable(int n,
    757575            int diffn,
     
    798616                    do
    799617                    {
    800                         if( x[j]<=x[j+g] )
     618                        if( (double)(x[j])<=(double)(x[j+g]) )
    801619                        {
    802620                            c = false;
     
    892710
    893711
    894         /*************************************************************************
    895         Obsolete subroutine, left for backward compatibility.
    896         *************************************************************************/
    897712        public static double spline3interpolate(int n,
    898713            ref double[,] c,
     
    913728                half = l/2;
    914729                middle = first+half;
    915                 if( c[4,middle]<x )
     730                if( (double)(c[4,middle])<(double)(x) )
    916731                {
    917732                    first = middle+1;
     
    933748
    934749
    935         /*************************************************************************
    936         Internal subroutine. Heap sort.
    937         *************************************************************************/
    938750        private static void heapsortpoints(ref double[] x,
    939751            ref double[] y,
     
    956768            for(i=1; i<=n-1; i++)
    957769            {
    958                 isascending = isascending & x[i]>x[i-1];
    959                 isdescending = isdescending & x[i]<x[i-1];
     770                isascending = isascending & (double)(x[i])>(double)(x[i-1]);
     771                isdescending = isdescending & (double)(x[i])<(double)(x[i-1]);
    960772            }
    961773            if( isascending )
     
    1000812                {
    1001813                    k = t/2;
    1002                     if( x[k-1]>=x[t-1] )
     814                    if( (double)(x[k-1])>=(double)(x[t-1]) )
    1003815                    {
    1004816                        t = 1;
     
    1039851                        if( k<i )
    1040852                        {
    1041                             if( x[k]>x[k-1] )
     853                            if( (double)(x[k])>(double)(x[k-1]) )
    1042854                            {
    1043855                                k = k+1;
    1044856                            }
    1045857                        }
    1046                         if( x[t-1]>=x[k-1] )
     858                        if( (double)(x[t-1])>=(double)(x[k-1]) )
    1047859                        {
    1048860                            t = 0;
     
    1066878
    1067879
    1068         /*************************************************************************
    1069         Internal subroutine. Heap sort.
    1070         *************************************************************************/
    1071880        private static void heapsortdpoints(ref double[] x,
    1072881            ref double[] y,
     
    1090899            for(i=1; i<=n-1; i++)
    1091900            {
    1092                 isascending = isascending & x[i]>x[i-1];
    1093                 isdescending = isdescending & x[i]<x[i-1];
     901                isascending = isascending & (double)(x[i])>(double)(x[i-1]);
     902                isdescending = isdescending & (double)(x[i])<(double)(x[i-1]);
    1094903            }
    1095904            if( isascending )
     
    1137946                {
    1138947                    k = t/2;
    1139                     if( x[k-1]>=x[t-1] )
     948                    if( (double)(x[k-1])>=(double)(x[t-1]) )
    1140949                    {
    1141950                        t = 1;
     
    1182991                        if( k<i )
    1183992                        {
    1184                             if( x[k]>x[k-1] )
     993                            if( (double)(x[k])>(double)(x[k-1]) )
    1185994                            {
    1186995                                k = k+1;
    1187996                            }
    1188997                        }
    1189                         if( x[t-1]>=x[k-1] )
     998                        if( (double)(x[t-1])>=(double)(x[k-1]) )
    1190999                        {
    11911000                            t = 0;
     
    12121021
    12131022
    1214         /*************************************************************************
    1215         Internal subroutine. Tridiagonal solver.
    1216         *************************************************************************/
    12171023        private static void solvetridiagonal(double[] a,
    12181024            double[] b,
     
    12471053
    12481054
    1249         /*************************************************************************
    1250         Internal subroutine. Three-point differentiation
    1251         *************************************************************************/
    12521055        private static double diffthreepoint(double t,
    12531056            double x0,
  • trunk/sources/ALGLIB/svd.cs

    r2430 r2563  
    154154            // Use bidiagonal reduction with QR-decomposition
    155155            //
    156             if( m>1.6*n )
     156            if( (double)(m)>(double)(1.6*n) )
    157157            {
    158158                if( uneeded==0 )
     
    224224            // Use bidiagonal reduction with LQ-decomposition
    225225            //
    226             if( n>1.6*m )
     226            if( (double)(n)>(double)(1.6*m) )
    227227            {
    228228                if( vtneeded==0 )
     
    341341
    342342
    343         /*************************************************************************
    344         Obsolete 1-based subroutine.
    345         See RMatrixSVD for 0-based replacement.
    346         *************************************************************************/
    347343        public static bool svddecomposition(double[,] a,
    348344            int m,
     
    422418            // Use bidiagonal reduction with QR-decomposition
    423419            //
    424             if( m>1.6*n )
     420            if( (double)(m)>(double)(1.6*n) )
    425421            {
    426422                if( uneeded==0 )
     
    492488            // Use bidiagonal reduction with LQ-decomposition
    493489            //
    494             if( n>1.6*m )
     490            if( (double)(n)>(double)(1.6*m) )
    495491            {
    496492                if( vtneeded==0 )
Note: See TracChangeset for help on using the changeset viewer.