Changeset aad4ca4 in git for Singular/svd


Ignore:
Timestamp:
Dec 6, 2017, 7:05:25 PM (6 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
Children:
06b3e84d21e073249ada6d3b863bb3b8ce91d3be
Parents:
3803c6a39fad57f9a8e12942b2928c215504e027
Message:
format: Warn -> WarnS, trailing spaces
Location:
Singular/svd
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • Singular/svd/bdsvd.h

    r3803c6 raad4ca4  
    346346            return result;
    347347        }
    348        
     348
    349349        //
    350350        // init
     
    363363        rightside = true;
    364364        fwddir = true;
    365        
     365
    366366        //
    367367        // resize E from N-1 to N
     
    379379        e(n) = 0;
    380380        idir = 0;
    381        
     381
    382382        //
    383383        // Get machine constants
     
    385385        eps = amp::ampf<Precision>::getAlgoPascalEpsilon();
    386386        unfl = amp::ampf<Precision>::getAlgoPascalMinNumber();
    387        
     387
    388388        //
    389389        // If matrix lower bidiagonal, rotate to be upper bidiagonal
     
    401401                work1(i) = sn;
    402402            }
    403            
     403
    404404            //
    405405            // Update singular vectors if desired
     
    414414            }
    415415        }
    416        
     416
    417417        //
    418418        // Compute singular values to relative accuracy TOL
     
    426426            tol = -tol;
    427427        }
    428        
     428
    429429        //
    430430        // Compute approximate maximum, minimum singular values
     
    442442        if( tol>=0 )
    443443        {
    444            
     444
    445445            //
    446446            // Relative accuracy desired
     
    465465        else
    466466        {
    467            
     467
    468468            //
    469469            // Absolute accuracy desired
     
    471471            thresh = amp::maximum<Precision>(amp::abs<Precision>(tol)*smax, maxitr*n*n*unfl);
    472472        }
    473        
     473
    474474        //
    475475        // Prepare for main iteration loop for the singular values
     
    481481        oldll = -1;
    482482        oldm = -1;
    483        
     483
    484484        //
    485485        // M points to last element of unconverged part of matrix
    486486        //
    487487        m = n;
    488        
     488
    489489        //
    490490        // Begin main iteration loop
     
    492492        while( true )
    493493        {
    494            
     494
    495495            //
    496496            // Check for convergence or exceeding iteration count
     
    505505                return result;
    506506            }
    507            
     507
    508508            //
    509509            // Find diagonal block of matrix to work on
     
    539539            else
    540540            {
    541                
     541
    542542                //
    543543                // Matrix splits since E(LL) = 0
     
    546546                if( ll==m-1 )
    547547                {
    548                    
     548
    549549                    //
    550550                    // Convergence of bottom singular value, return to top of loop
     
    555555            }
    556556            ll = ll+1;
    557            
     557
    558558            //
    559559            // E(LL) through E(M-1) are nonzero, E(LL-1) is zero
     
    561561            if( ll==m-1 )
    562562            {
    563                
     563
    564564                //
    565565                // 2 by 2 block, handle separately
     
    569569                e(m-1) = 0;
    570570                d(m) = sigmn;
    571                
     571
    572572                //
    573573                // Compute singular vectors, if desired
     
    606606                continue;
    607607            }
    608            
     608
    609609            //
    610610            // If working on new submatrix, choose shift direction
     
    629629                if( amp::abs<Precision>(d(ll))>=amp::abs<Precision>(d(m)) )
    630630                {
    631                    
     631
    632632                    //
    633633                    // Chase bulge from top (big end) to bottom (small end)
     
    637637                else
    638638                {
    639                    
     639
    640640                    //
    641641                    // Chase bulge from bottom (big end) to top (small end)
     
    644644                }
    645645            }
    646            
     646
    647647            //
    648648            // Apply convergence tests
     
    650650            if( idir==1 )
    651651            {
    652                
     652
    653653                //
    654654                // Run convergence test in forward direction
     
    662662                if( tol>=0 )
    663663                {
    664                    
     664
    665665                    //
    666666                    // If relative accuracy desired,
     
    690690            else
    691691            {
    692                
     692
    693693                //
    694694                // Run convergence test in backward direction
     
    702702                if( tol>=0 )
    703703                {
    704                    
     704
    705705                    //
    706706                    // If relative accuracy desired,
     
    730730            oldll = ll;
    731731            oldm = m;
    732            
     732
    733733            //
    734734            // Compute shift.  First, test if shifting would ruin relative
     
    737737            if( tol>=0 && n*tol*(sminl/smax)<=amp::maximum<Precision>(eps, amp::ampf<Precision>("0.01")*tol) )
    738738            {
    739                
     739
    740740                //
    741741                // Use a zero shift to avoid loss of relative accuracy
     
    745745            else
    746746            {
    747                
     747
    748748                //
    749749                // Compute the shift from 2-by-2 block at end of matrix
     
    759759                    svd2x2<Precision>(d(ll), e(ll), d(ll+1), shift, r);
    760760                }
    761                
     761
    762762                //
    763763                // Test if shift negligible, and if so set to zero
     
    771771                }
    772772            }
    773            
     773
    774774            //
    775775            // Increment iteration count
    776776            //
    777777            iter = iter+m-ll;
    778            
     778
    779779            //
    780780            // If SHIFT = 0, do simplified QR iteration
     
    784784                if( idir==1 )
    785785                {
    786                    
     786
    787787                    //
    788788                    // Chase bulge from top to bottom
     
    808808                    d(m) = h*oldcs;
    809809                    e(m-1) = h*oldsn;
    810                    
     810
    811811                    //
    812812                    // Update singular vectors
     
    824824                        rotations::applyrotationsfromtheleft<Precision>(fwddir, ll+cstart-1, m+cstart-1, cstart, cend, work2, work3, c, ctemp);
    825825                    }
    826                    
     826
    827827                    //
    828828                    // Test convergence
     
    835835                else
    836836                {
    837                    
     837
    838838                    //
    839839                    // Chase bulge from bottom to top
     
    859859                    d(ll) = h*oldcs;
    860860                    e(ll) = h*oldsn;
    861                    
     861
    862862                    //
    863863                    // Update singular vectors
     
    875875                        rotations::applyrotationsfromtheleft<Precision>(!fwddir, ll+cstart-1, m+cstart-1, cstart, cend, work0, work1, c, ctemp);
    876876                    }
    877                    
     877
    878878                    //
    879879                    // Test convergence
     
    887887            else
    888888            {
    889                
     889
    890890                //
    891891                // Use nonzero shift
     
    893893                if( idir==1 )
    894894                {
    895                    
     895
    896896                    //
    897897                    // Chase bulge from top to bottom
     
    926926                    }
    927927                    e(m-1) = f;
    928                    
     928
    929929                    //
    930930                    // Update singular vectors
     
    942942                        rotations::applyrotationsfromtheleft<Precision>(fwddir, ll+cstart-1, m+cstart-1, cstart, cend, work2, work3, c, ctemp);
    943943                    }
    944                    
     944
    945945                    //
    946946                    // Test convergence
     
    953953                else
    954954                {
    955                    
     955
    956956                    //
    957957                    // Chase bulge from bottom to top
     
    986986                    }
    987987                    e(ll) = f;
    988                    
     988
    989989                    //
    990990                    // Test convergence
     
    994994                        e(ll) = 0;
    995995                    }
    996                    
     996
    997997                    //
    998998                    // Update singular vectors if desired
     
    10121012                }
    10131013            }
    1014            
     1014
    10151015            //
    10161016            // QR iteration finished, go back and check convergence
     
    10181018            continue;
    10191019        }
    1020        
     1020
    10211021        //
    10221022        // All singular values converged, so make them positive
     
    10271027            {
    10281028                d(i) = -d(i);
    1029                
     1029
    10301030                //
    10311031                // Change sign of singular vectors, if desired
     
    10371037            }
    10381038        }
    1039        
     1039
    10401040        //
    10411041        // Sort the singular values into decreasing order (insertion sort on
     
    10441044        for(i=1; i<=n-1; i++)
    10451045        {
    1046            
     1046
    10471047            //
    10481048            // Scan for smallest D(I)
     
    10601060            if( isub!=n+1-i )
    10611061            {
    1062                
     1062
    10631063                //
    10641064                // Swap singular values and vectors
     
    11631163                if( au==0 )
    11641164                {
    1165                    
     1165
    11661166                    //
    11671167                    // Avoid possible harmful underflow if exponent range
     
    12281228        ht = h;
    12291229        ha = amp::abs<Precision>(h);
    1230        
     1230
    12311231        //
    12321232        // PMAX points to the maximum absolute element of matrix
     
    12391239        if( swp )
    12401240        {
    1241            
     1241
    12421242            //
    12431243            // Now FA .ge. HA
     
    12551255        if( ga==0 )
    12561256        {
    1257            
     1257
    12581258            //
    12591259            // Diagonal matrix
     
    12741274                if( fa/ga<amp::ampf<Precision>::getAlgoPascalEpsilon() )
    12751275                {
    1276                    
     1276
    12771277                    //
    12781278                    // Case of very large GA
     
    12981298            if( gasmal )
    12991299            {
    1300                
     1300
    13011301                //
    13021302                // Normal case
     
    13291329                if( mm==0 )
    13301330                {
    1331                    
     1331
    13321332                    //
    13331333                    // Note that M is very tiny
     
    13681368            snr = srt;
    13691369        }
    1370        
     1370
    13711371        //
    13721372        // Correct signs of SSMAX and SSMIN
  • Singular/svd/bidiagonal.h

    r3803c6 raad4ca4  
    207207
    208208
    209        
     209
    210210        //
    211211        // Prepare
     
    231231        if( m>=n )
    232232        {
    233            
     233
    234234            //
    235235            // Reduce to upper bidiagonal form
     
    237237            for(i=0; i<=n-1; i++)
    238238            {
    239                
     239
    240240                //
    241241                // Generate elementary reflector H(i) to annihilate A(i+1:m-1,i)
     
    246246                ap::vmove(a.getcolumn(i, i, m-1), t.getvector(1, m-i));
    247247                t(1) = 1;
    248                
     248
    249249                //
    250250                // Apply H(i) to A(i:m-1,i+1:n-1) from the left
     
    253253                if( i<n-1 )
    254254                {
    255                    
     255
    256256                    //
    257257                    // Generate elementary reflector G(i) to annihilate
     
    263263                    ap::vmove(a.getrow(i, i+1, n-1), t.getvector(1, n-1-i));
    264264                    t(1) = 1;
    265                    
     265
    266266                    //
    267267                    // Apply G(i) to A(i+1:m-1,i+1:n-1) from the right
     
    277277        else
    278278        {
    279            
     279
    280280            //
    281281            // Reduce to lower bidiagonal form
     
    283283            for(i=0; i<=m-1; i++)
    284284            {
    285                
     285
    286286                //
    287287                // Generate elementary reflector G(i) to annihilate A(i,i+1:n-1)
     
    292292                ap::vmove(a.getrow(i, i, n-1), t.getvector(1, n-i));
    293293                t(1) = 1;
    294                
     294
    295295                //
    296296                // Apply G(i) to A(i+1:m-1,i:n-1) from the right
     
    299299                if( i<m-1 )
    300300                {
    301                    
     301
    302302                    //
    303303                    // Generate elementary reflector H(i) to annihilate
     
    309309                    ap::vmove(a.getcolumn(i, i+1, m-1), t.getvector(1, m-1-i));
    310310                    t(1) = 1;
    311                    
     311
    312312                    //
    313313                    // Apply H(i) to A(i+1:m-1,i+1:n-1) from the left
     
    363363            return;
    364364        }
    365        
     365
    366366        //
    367367        // prepare Q
     
    382382            }
    383383        }
    384        
     384
    385385        //
    386386        // Calculate
     
    444444        }
    445445        ap::ap_error::make_assertion(fromtheright && zcolumns==m || !fromtheright && zrows==m);
    446        
     446
    447447        //
    448448        // init
     
    455455        if( m>=n )
    456456        {
    457            
     457
    458458            //
    459459            // setup
     
    478478                istep = -istep;
    479479            }
    480            
     480
    481481            //
    482482            // Process
     
    501501        else
    502502        {
    503            
     503
    504504            //
    505505            // setup
     
    524524                istep = -istep;
    525525            }
    526            
     526
    527527            //
    528528            // Process
     
    590590            return;
    591591        }
    592        
     592
    593593        //
    594594        // prepare PT
     
    609609            }
    610610        }
    611        
     611
    612612        //
    613613        // Calculate
     
    671671        }
    672672        ap::ap_error::make_assertion(fromtheright && zcolumns==n || !fromtheright && zrows==n);
    673        
     673
    674674        //
    675675        // init
     
    684684        if( m>=n )
    685685        {
    686            
     686
    687687            //
    688688            // setup
     
    707707                istep = -istep;
    708708            }
    709            
     709
    710710            //
    711711            // Process
     
    733733        else
    734734        {
    735            
     735
    736736            //
    737737            // setup
     
    756756                istep = -istep;
    757757            }
    758            
     758
    759759            //
    760760            // Process
     
    875875        if( m>=n )
    876876        {
    877            
     877
    878878            //
    879879            // Reduce to upper bidiagonal form
     
    881881            for(i=1; i<=n; i++)
    882882            {
    883                
     883
    884884                //
    885885                // Generate elementary reflector H(i) to annihilate A(i+1:m,i)
     
    891891                ap::vmove(a.getcolumn(i, i, m), t.getvector(1, mmip1));
    892892                t(1) = 1;
    893                
     893
    894894                //
    895895                // Apply H(i) to A(i:m,i+1:n) from the left
     
    898898                if( i<n )
    899899                {
    900                    
     900
    901901                    //
    902902                    // Generate elementary reflector G(i) to annihilate
     
    910910                    ap::vmove(a.getrow(i, ip1, n), t.getvector(1, nmi));
    911911                    t(1) = 1;
    912                    
     912
    913913                    //
    914914                    // Apply G(i) to A(i+1:m,i+1:n) from the right
     
    924924        else
    925925        {
    926            
     926
    927927            //
    928928            // Reduce to lower bidiagonal form
     
    930930            for(i=1; i<=m; i++)
    931931            {
    932                
     932
    933933                //
    934934                // Generate elementary reflector G(i) to annihilate A(i,i+1:n)
     
    940940                ap::vmove(a.getrow(i, i, n), t.getvector(1, nmip1));
    941941                t(1) = 1;
    942                
     942
    943943                //
    944944                // Apply G(i) to A(i+1:m,i:n) from the right
     
    947947                if( i<m )
    948948                {
    949                    
     949
    950950                    //
    951951                    // Generate elementary reflector H(i) to annihilate
     
    959959                    ap::vmove(a.getcolumn(i, ip1, m), t.getvector(1, mmi));
    960960                    t(1) = 1;
    961                    
     961
    962962                    //
    963963                    // Apply H(i) to A(i+1:m,i+1:n) from the left
     
    999999            return;
    10001000        }
    1001        
     1001
    10021002        //
    10031003        // init
     
    10061006        v.setbounds(1, m);
    10071007        work.setbounds(1, qcolumns);
    1008        
     1008
    10091009        //
    10101010        // prepare Q
     
    10791079        }
    10801080        ap::ap_error::make_assertion(fromtheright && zcolumns==m || !fromtheright && zrows==m);
    1081        
     1081
    10821082        //
    10831083        // init
     
    10901090        if( m>=n )
    10911091        {
    1092            
     1092
    10931093            //
    10941094            // setup
     
    11131113                istep = -istep;
    11141114            }
    1115            
     1115
    11161116            //
    11171117            // Process
     
    11371137        else
    11381138        {
    1139            
     1139
    11401140            //
    11411141            // setup
     
    11601160                istep = -istep;
    11611161            }
    1162            
     1162
    11631163            //
    11641164            // Process
     
    12141214            return;
    12151215        }
    1216        
     1216
    12171217        //
    12181218        // init
     
    12211221        v.setbounds(1, n);
    12221222        work.setbounds(1, ptrows);
    1223        
     1223
    12241224        //
    12251225        // prepare PT
     
    12941294        }
    12951295        ap::ap_error::make_assertion(fromtheright && zcolumns==n || !fromtheright && zrows==n);
    1296        
     1296
    12971297        //
    12981298        // init
     
    13071307        if( m>=n )
    13081308        {
    1309            
     1309
    13101310            //
    13111311            // setup
     
    13301330                istep = -istep;
    13311331            }
    1332            
     1332
    13331333            //
    13341334            // Process
     
    13581358        else
    13591359        {
    1360            
     1360
    13611361            //
    13621362            // setup
     
    13811381                istep = -istep;
    13821382            }
    1383            
     1383
    13841384            //
    13851385            // Process
  • Singular/svd/blas.h

    r3803c6 raad4ca4  
    400400        if( !trans )
    401401        {
    402            
     402
    403403            //
    404404            // y := alpha*A*x + beta*y;
     
    410410            ap::ap_error::make_assertion(j2-j1==ix2-ix1);
    411411            ap::ap_error::make_assertion(i2-i1==iy2-iy1);
    412            
     412
    413413            //
    414414            // beta*y
     
    425425                ap::vmul(y.getvector(iy1, iy2), beta);
    426426            }
    427            
     427
    428428            //
    429429            // alpha*A*x
     
    437437        else
    438438        {
    439            
     439
    440440            //
    441441            // y := alpha*A'*x + beta*y;
     
    447447            ap::ap_error::make_assertion(i2-i1==ix2-ix1);
    448448            ap::ap_error::make_assertion(j2-j1==iy2-iy1);
    449            
     449
    450450            //
    451451            // beta*y
     
    462462                ap::vmul(y.getvector(iy1, iy2), beta);
    463463            }
    464            
     464
    465465            //
    466466            // alpha*A'*x
     
    538538
    539539
    540        
     540
    541541        //
    542542        // Setup
     
    569569        crows = arows;
    570570        ccols = bcols;
    571        
     571
    572572        //
    573573        // Test WORK
     
    578578        work(1) = 0;
    579579        work(i) = 0;
    580        
     580
    581581        //
    582582        // Prepare C
     
    599599            }
    600600        }
    601        
     601
    602602        //
    603603        // A*B
     
    616616            return;
    617617        }
    618        
     618
    619619        //
    620620        // A*B'
     
    647647            }
    648648        }
    649        
     649
    650650        //
    651651        // A'*B
     
    664664            return;
    665665        }
    666        
     666
    667667        //
    668668        // A'*B'
  • Singular/svd/libs/amp.cpp

    r3803c6 raad4ca4  
    2020        lst = rec;
    2121    }
    22    
     22
    2323    amp::mpfr_record *p = lst;
    2424    p->refCount = 1;
     
    111111        free();
    112112}
    113        
     113
    114114void amp::mpfr_reference::initialize(int Precision)
    115115{
     
    130130    ref = NULL;
    131131}
    132        
     132
    133133mpfr_srcptr amp::mpfr_reference::getReadPtr() const
    134134{
     
    149149    amp::mpfr_record *newref = amp::mpfr_storage::newMpfr(ref->Precision);
    150150    mpfr_set(newref->value, ref->value, GMP_RNDN);
    151    
     151
    152152    free();
    153153    ref = newref;
  • Singular/svd/libs/amp.english.html

    r3803c6 raad4ca4  
    128128        ~ampf();
    129129
    130         ampf ();       
     130        ampf ();
    131131        ampf (<b>long double</b> v);
    132132        ampf (<b>double</b> v);
     
    142142        ampf (<b>const</b> std::string &amp;s);
    143143        ampf (<b>const char</b> *s);
    144        
     144
    145145        ampf(<b>const</b> ampf&amp; r);
    146146        <b>template</b>&lt;<b>unsigned int</b> Precision2&gt;
     
    163163        <b>template</b>&lt;<b>unsigned int</b> Precision2&gt;
    164164        ampf&amp; <b>operator</b>= (<b>const</b> ampf&lt;Precision2&gt;&amp; r);
    165        
     165
    166166        <b>template</b>&lt;<b>class</b> T&gt;
    167167        ampf&amp; <b>operator</b>+=(<b>const</b> T&amp; v);
     
    172172        <b>template</b>&lt;class T&gt;
    173173        ampf&amp; <b>operator</b>/=(<b>const</b> T&amp; v);
    174        
     174
    175175        mpfr_srcptr getReadPtr() <b>const</b>;
    176176        mpfr_ptr getWritePtr();
    177        
     177
    178178        <b>bool</b> isFiniteNumber() <b>const</b>;
    179179        <b>bool</b> isPositiveNumber() <b>const</b>;
     
    185185        std::string toHex() <b>const</b>;
    186186        std::string toDec() <b>const</b>;
    187        
     187
    188188        <b>static const</b> ampf getUlpOf(<b>const</b> ampf &amp;x);
    189189        <b>static const</b> ampf getUlp();
     
    499499Calculates the arc tangent of y/x. It produces correct results even when the resulting angle is near pi/2 or -pi/2 (x near 0).
    500500</p>
    501    
     501
    502502<p>
    503503<span class=func>
  • Singular/svd/libs/amp.h

    r3803c6 raad4ca4  
    1919namespace amp
    2020{
    21     class exception {}; 
     21    class exception {};
    2222    class incorrectPrecision    : public exception {};
    2323    class overflow              : public exception {};
     
    2828    class internalError         : public exception {};
    2929    class domainError           : public exception {};
    30    
     30
    3131    typedef unsigned long unsigned32;
    3232    typedef signed long   signed32;
    33    
     33
    3434    struct mpfr_record
    3535    {
     
    3939        mpfr_record *next;
    4040    };
    41    
     41
    4242    typedef mpfr_record* mpfr_record_ptr;
    43    
     43
    4444    //
    4545    // storage for mpfr_t instances
     
    4747    class mpfr_storage
    4848    {
    49     public:       
     49    public:
    5050        static mpfr_record* newMpfr(unsigned int Precision);
    5151        static void deleteMpfr(mpfr_record* ref);
     
    5555        static mpfr_record_ptr& getList(unsigned int Precision);
    5656    };
    57    
     57
    5858    //
    5959    // mpfr_t reference
     
    6666        mpfr_reference& operator= (const mpfr_reference &r);
    6767        ~mpfr_reference();
    68        
     68
    6969        void initialize(int Precision);
    7070        void free();
    71        
     71
    7272        mpfr_srcptr getReadPtr() const;
    7373        mpfr_ptr getWritePtr();
     
    7575        mpfr_record *ref;
    7676    };
    77        
     77
    7878    //
    7979    // ampf template
     
    9292                mpfr_storage::deleteMpfr(rval);
    9393        }
    94        
     94
    9595        //
    9696        // Initializing
     
    9898        ampf ()                 { InitializeAsZero(); }
    9999        ampf(mpfr_record *v)    { rval = v; }
    100        
     100
    101101        ampf (long double v)    { InitializeAsDouble(v); }
    102102        ampf (double v)         { InitializeAsDouble(v); }
     
    110110        ampf (signed char v)    { InitializeAsSLong(v); }
    111111        ampf (unsigned char v)  { InitializeAsULong(v); }
    112        
     112
    113113        //
    114114        // initializing from string
     
    117117        ampf (const std::string &s) { InitializeAsString(s.c_str()); }
    118118        ampf (const char *s)        { InitializeAsString(s); }
    119        
     119
    120120        //
    121121        // copy constructors
     
    177177        }
    178178#endif
    179        
     179
    180180        //
    181181        // in-place operators
     
    186186        template<class T> ampf& operator*=(const T& v){ *this = *this * v; return *this; };
    187187        template<class T> ampf& operator/=(const T& v){ *this = *this / v; return *this; };
    188        
     188
    189189        //
    190190        // MPFR access
     
    192192        mpfr_srcptr getReadPtr() const;
    193193        mpfr_ptr getWritePtr();
    194        
     194
    195195        //
    196196        // properties and information
     
    209209        std::string toDec() const;
    210210        char * toString() const;
    211        
    212        
     211
     212
    213213        //
    214214        // static methods
    215         //       
     215        //
    216216        static const ampf getUlpOf(const ampf &x);
    217217        static const ampf getUlp();
     
    231231        void InitializeAsDouble(long double v);
    232232        void InitializeAsString(const char *s);
    233        
     233
    234234        //mpfr_reference  ref;
    235235        mpfr_record *rval;
     
    264264        mpfr_set_si(getWritePtr(), sv, GMP_RNDN);
    265265    }
    266    
     266
    267267    template<unsigned int Precision>
    268268    void ampf<Precision>::InitializeAsULong(unsigned long v)
     
    272272        mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
    273273    }
    274                            
     274
    275275    template<unsigned int Precision>
    276276    void ampf<Precision>::InitializeAsDouble(long double v)
     
    287287        rval = mpfr_storage::newMpfr(Precision);
    288288        mpfr_strtofr(getWritePtr(), s, NULL, 0, GMP_RNDN);
    289     } 
     289    }
    290290
    291291    template<unsigned int Precision>
    292292    mpfr_srcptr ampf<Precision>::getReadPtr() const
    293293    {
    294         // TODO: ïîäóìàòü, íóæíî ëè ñäåëàòü, ÷òîáû è ïðè getRead, è ïðè 
     294        // TODO: ïîäóìàòü, íóæíî ëè ñäåëàòü, ÷òîáû è ïðè getRead, è ïðè
    295295        //       getWrite ñîçäàâàëàñü íîâàÿ instance mpfr_t.
    296296        //       ýòî ìîæåò áûòü íóæíî äëÿ êîððåêòíîé îáðàáîòêè ñèòóàöèé âèäà
     
    299299        return rval->value;
    300300    }
    301    
     301
    302302    template<unsigned int Precision>
    303303    mpfr_ptr ampf<Precision>::getWritePtr()
     
    311311        return rval->value;
    312312    }
    313        
     313
    314314    template<unsigned int Precision>
    315315    bool ampf<Precision>::isFiniteNumber() const
     
    325325        return mpfr_sgn(getReadPtr())>0;
    326326    }
    327    
     327
    328328    template<unsigned int Precision>
    329329    bool ampf<Precision>::isZero() const
     
    331331        return mpfr_zero_p(getReadPtr())!=0;
    332332    }
    333    
     333
    334334    template<unsigned int Precision>
    335335    bool ampf<Precision>::isNegativeNumber() const
     
    345345        return getUlpOf(*this);
    346346    }
    347    
     347
    348348    template<unsigned int Precision>
    349349    double ampf<Precision>::toDouble() const
     
    351351        return mpfr_get_d(getReadPtr(), GMP_RNDN);
    352352    }
    353    
     353
    354354    template<unsigned int Precision>
    355355    std::string ampf<Precision>::toHex() const
     
    368368            return r;
    369369        }
    370        
     370
    371371        //
    372372        // general case
     
    396396        return r;
    397397    }
    398    
     398
    399399    template<unsigned int Precision>
    400400    std::string ampf<Precision>::toDec() const
    401401    {
    402402        // TODO: advanced output formatting (zero, integers)
    403        
     403
    404404        //
    405405        // some special cases
     
    415415            return r;
    416416        }
    417        
     417
    418418        //
    419419        // general case
     
    459459            return toString_Block;
    460460        }
    461        
     461
    462462        //
    463463        // general case
     
    508508        return r;
    509509    }
    510        
     510
    511511    template<unsigned int Precision>
    512512    const ampf<Precision> ampf<Precision>::getUlp()
     
    517517        return r;
    518518    }
    519    
     519
    520520    template<unsigned int Precision>
    521521    const ampf<Precision> ampf<Precision>::getUlp256()
     
    531531        return r;
    532532    }
    533    
     533
    534534    template<unsigned int Precision>
    535535    const ampf<Precision> ampf<Precision>::getUlp512()
     
    544544            GMP_RNDN);
    545545        return r;
    546     } 
     546    }
    547547
    548548    template<unsigned int Precision>
     
    554554        return r;
    555555    }
    556    
     556
    557557    template<unsigned int Precision>
    558558    const ampf<Precision> ampf<Precision>::getMinNumber()
     
    568568        return getUlp256();
    569569    }
    570    
     570
    571571    template<unsigned int Precision>
    572572    const ampf<Precision> ampf<Precision>::getAlgoPascalMaxNumber()
     
    579579        return r;
    580580    }
    581    
     581
    582582    template<unsigned int Precision>
    583583    const ampf<Precision> ampf<Precision>::getAlgoPascalMinNumber()
     
    598598        return r;
    599599    }
    600    
     600
    601601    //
    602602    // comparison operators
     
    613613        return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())!=0;
    614614    }
    615    
     615
    616616    template<unsigned int Precision>
    617617    const bool operator<(const ampf<Precision>& op1, const ampf<Precision>& op2)
     
    619619        return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())<0;
    620620    }
    621    
     621
    622622    template<unsigned int Precision>
    623623    const bool operator>(const ampf<Precision>& op1, const ampf<Precision>& op2)
     
    625625        return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())>0;
    626626    }
    627    
     627
    628628    template<unsigned int Precision>
    629629    const bool operator<=(const ampf<Precision>& op1, const ampf<Precision>& op2)
     
    631631        return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())<=0;
    632632    }
    633    
     633
    634634    template<unsigned int Precision>
    635635    const bool operator>=(const ampf<Precision>& op1, const ampf<Precision>& op2)
     
    637637        return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())>=0;
    638638    }
    639    
     639
    640640    //
    641641    // arithmetic operators
     
    646646        return op1;
    647647    }
    648    
     648
    649649    template<unsigned int Precision>
    650650    const ampf<Precision> operator-(const ampf<Precision>& op1)
     
    654654        return v;
    655655    }
    656    
     656
    657657    template<unsigned int Precision>
    658658    const ampf<Precision> operator+(const ampf<Precision>& op1, const ampf<Precision>& op2)
     
    662662        return v;
    663663    }
    664    
     664
    665665    template<unsigned int Precision>
    666666    const ampf<Precision> operator-(const ampf<Precision>& op1, const ampf<Precision>& op2)
     
    670670        return v;
    671671    }
    672        
    673    
     672
     673
    674674    template<unsigned int Precision>
    675675    const ampf<Precision> operator*(const ampf<Precision>& op1, const ampf<Precision>& op2)
     
    679679        return v;
    680680    }
    681    
     681
    682682    template<unsigned int Precision>
    683683    const ampf<Precision> operator/(const ampf<Precision>& op1, const ampf<Precision>& op2)
     
    687687        return v;
    688688    }
    689  
     689
    690690    //
    691691    // basic functions
     
    843843        return r;
    844844    }
    845  
     845
    846846    //
    847847    // different types of arguments
     
    918918    __AMP_BINARY_OPF(long double)
    919919    #undef __AMP_BINARY_OPF
    920    
     920
    921921    //
    922922    // transcendent functions
     
    10031003        return v;
    10041004    }
    1005    
     1005
    10061006    template<unsigned int Precision>
    10071007    const ampf<Precision> log(const ampf<Precision> &x)
     
    10771077        campf():x(0),y(0){};
    10781078        campf(long double v)    { x=v; y=0; }
    1079         campf(double v)         { x=v; y=0; } 
     1079        campf(double v)         { x=v; y=0; }
    10801080        campf(float v)          { x=v; y=0; }
    10811081        campf(signed long v)    { x=v; y=0; }
     
    11261126        ampf<Precision> x, y;
    11271127    };
    1128    
     1128
    11291129    //
    11301130    // complex operations
     
    11331133    const bool operator==(const campf<Precision>& lhs, const campf<Precision>& rhs)
    11341134    { return lhs.x==rhs.x && lhs.y==rhs.y; }
    1135    
     1135
    11361136    template<unsigned int Precision>
    11371137    const bool operator!=(const campf<Precision>& lhs, const campf<Precision>& rhs)
    11381138    { return lhs.x!=rhs.x || lhs.y!=rhs.y; }
    1139    
     1139
    11401140    template<unsigned int Precision>
    11411141    const campf<Precision> operator+(const campf<Precision>& lhs)
    11421142    { return lhs; }
    1143    
     1143
    11441144    template<unsigned int Precision>
    11451145    campf<Precision>& operator+=(campf<Precision>& lhs, const campf<Precision>& rhs)
    11461146    { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
    1147    
     1147
    11481148    template<unsigned int Precision>
    11491149    const campf<Precision> operator+(const campf<Precision>& lhs, const campf<Precision>& rhs)
    11501150    { campf<Precision> r = lhs; r += rhs; return r; }
    1151    
     1151
    11521152    template<unsigned int Precision>
    11531153    const campf<Precision> operator-(const campf<Precision>& lhs)
    11541154    { return campf<Precision>(-lhs.x, -lhs.y); }
    1155    
     1155
    11561156    template<unsigned int Precision>
    11571157    campf<Precision>& operator-=(campf<Precision>& lhs, const campf<Precision>& rhs)
    11581158    { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
    1159    
     1159
    11601160    template<unsigned int Precision>
    11611161    const campf<Precision> operator-(const campf<Precision>& lhs, const campf<Precision>& rhs)
    11621162    { campf<Precision> r = lhs; r -= rhs; return r; }
    1163    
     1163
    11641164    template<unsigned int Precision>
    11651165    campf<Precision>& operator*=(campf<Precision>& lhs, const campf<Precision>& rhs)
     
    11701170        return lhs;
    11711171    }
    1172    
     1172
    11731173    template<unsigned int Precision>
    11741174    const campf<Precision> operator*(const campf<Precision>& lhs, const campf<Precision>& rhs)
    11751175    { campf<Precision> r = lhs; r *= rhs; return r; }
    1176    
     1176
    11771177    template<unsigned int Precision>
    11781178    const campf<Precision> operator/(const campf<Precision>& lhs, const campf<Precision>& rhs)
     
    11971197        return result;
    11981198    }
    1199    
     1199
    12001200    template<unsigned int Precision>
    12011201    campf<Precision>& operator/=(campf<Precision>& lhs, const campf<Precision>& rhs)
     
    12041204        return lhs;
    12051205    }
    1206    
     1206
    12071207    template<unsigned int Precision>
    12081208    const ampf<Precision> abscomplex(const campf<Precision> &z)
    12091209    {
    12101210        ampf<Precision> w, xabs, yabs, v;
    1211    
     1211
    12121212        xabs = abs(z.x);
    12131213        yabs = abs(z.y);
    12141214        w = xabs>yabs ? xabs : yabs;
    1215         v = xabs<yabs ? xabs : yabs; 
     1215        v = xabs<yabs ? xabs : yabs;
    12161216        if( v==0 )
    12171217            return w;
     
    12221222        }
    12231223    }
    1224    
     1224
    12251225    template<unsigned int Precision>
    12261226    const campf<Precision> conj(const campf<Precision> &z)
    12271227    {
    1228         return campf<Precision>(z.x, -z.y); 
    1229     }
    1230    
     1228        return campf<Precision>(z.x, -z.y);
     1229    }
     1230
    12311231    template<unsigned int Precision>
    12321232    const campf<Precision> csqr(const campf<Precision> &z)
    12331233    {
    1234         ampf<Precision> t = z.x*z.y; 
    1235         return campf<Precision>(sqr(z.x)-sqr(z.y), t+t); 
    1236     }
    1237    
     1234        ampf<Precision> t = z.x*z.y;
     1235        return campf<Precision>(sqr(z.x)-sqr(z.y), t+t);
     1236    }
     1237
    12381238    //
    12391239    // different types of arguments
     
    12811281        template<unsigned int Precision>                   bool operator==(const campf<Precision>& op1, const type& op2)             { return op1.x==op2 && op1.y==0; }   \
    12821282        template<unsigned int Precision>                   bool operator!=(const type& op1,             const campf<Precision>& op2) { return op1!=op2.x || op2.y!=0; }   \
    1283         template<unsigned int Precision>                   bool operator!=(const campf<Precision>& op1, const type& op2)             { return op1.x!=op2 || op1.y!=0; }   
     1283        template<unsigned int Precision>                   bool operator!=(const campf<Precision>& op1, const type& op2)             { return op1.x!=op2 || op1.y!=0; }
    12841284    __AMP_BINARY_OPF(float)
    12851285    __AMP_BINARY_OPF(double)
     
    12871287    __AMP_BINARY_OPF(ampf<Precision>)
    12881288    #undef __AMP_BINARY_OPF
    1289    
     1289
    12901290    //
    12911291    // Real linear algebra
     
    13411341        }
    13421342    }
    1343    
     1343
    13441344    template<unsigned int Precision>
    13451345    void vMoveNeg(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc)
     
    13581358        }
    13591359    }
    1360    
     1360
    13611361    template<unsigned int Precision, class T2>
    13621362    void vMove(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc, T2 alpha)
     
    13761376        }
    13771377    }
    1378    
     1378
    13791379    template<unsigned int Precision>
    13801380    void vAdd(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc)
     
    13931393        }
    13941394    }
    1395    
     1395
    13961396    template<unsigned int Precision, class T2>
    13971397    void vAdd(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc, T2 alpha)
     
    14121412        }
    14131413    }
    1414    
     1414
    14151415    template<unsigned int Precision>
    14161416    void vSub(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc)
     
    14291429        }
    14301430    }
    1431    
     1431
    14321432    template<unsigned int Precision, class T2>
    14331433    void vSub(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc, T2 alpha)
     
    14351435        vAdd(vDst, vSrc, -alpha);
    14361436    }
    1437    
     1437
    14381438    template<unsigned int Precision, class T2>
    14391439    void vMul(ap::raw_vector< ampf<Precision> > vDst, T2 alpha)
     
    14501450    }
    14511451}
    1452  
     1452
    14531453#endif
  • Singular/svd/libs/amp.russian.html

    r3803c6 raad4ca4  
    7777
    7878<p>
    79 <b>Îïðåäåëåíèå òî÷íîñòè íà ýòàïå êîìïèëÿöèè</b>. Îñîáåííîñòüþ áèáëèîòåêè AMP ÿâëÿåòñÿ òî, ÷òî êëàññ, ïîçâîëÿþùèé îñóùåñòâëÿòü îïåðàöèè ñ âåùåñòâåííûìè ÷èñëàìè âûñîêîé òî÷íîñòè, ÿâëÿåòñÿ êëàññîì-øàáëîíîì, ïàðàìåòðîì êîòîðîãî ÿâëÿåòñÿ öåëîå ÷èñëî, çàäàþùåå òî÷íîñòü õðàíÿùåãîñÿ çíà÷åíèÿ. Òàêèì îáðàçîì, òî÷íîñòü, ñ êîòîðîé îñóùåñòâëÿþòñÿ âû÷èñëåíèÿ, ñòàíîâèòñÿ èçâåñòíà åùž íà ýòàïå êîìïèëÿöèè - ïðè ïàðàìåòðèçàöèè øàáëîíà, è íå ìîæåò áûòü èçìåíåíà â õîäå âûïîëíåíèÿ ïðîãðàììû. Ýòî ñóùåñòâåííîå îãðàíè÷åíèå ôóíêöèîíàëüíîñòè áèáëèîòåêè áûëî ââåäåíî ñîçíàòåëüíî. Ïðè÷èíîé ÿâëÿåòñÿ òî, ÷òî îñíîâíîå íàçíà÷åíèå áèáëèîòåêè AMP - ïðèìåíåíèå â ðàìêàõ ïðîåêòà ALGLIB.  ïðîåêòå ALGLIB áèáëèîòåêà AMP èñïîëüçóåòñÿ ïðîãðàììàìè, ÿâëÿþùèìèñÿ ðåçóëüòàòîì ðàáîòû àâòîìàòè÷åñêîãî òðàíñëÿòîðà. Ãåíåðèðóåìûé òðàíñëÿòîðîì êîä íå ñïîñîáåí ðàáîòàòü ñ âåùåñòâåííûìè ÷èñëàìè, ÷üÿ òî÷íîñòü ìåíÿåòñÿ äèíàìè÷åñêè, ïîñêîëüêó ïðè ýòîì âîçíèêàåò ðÿä ïðîáëåì (íàïðèìåð, êàêóþ òî÷íîñòü ñëåäóåò èñïîëüçîâàòü äëÿ ïðîìåæóòî÷íûõ ðåçóëüòàòîâ, åñëè îäíè ýëåìåíòû ìàòðèöû çàäàíû ñ òî÷íîñòüþ 128 áèò, à äðóãèå - ñ òî÷íîñòüþ 256 áèò). Ïî ýòîé ïðè÷èíå áûëî ðåøåíî ââåñòè âûøåóêàçàííîå îãðàíè÷åíèå. 
     79<b>Îïðåäåëåíèå òî÷íîñòè íà ýòàïå êîìïèëÿöèè</b>. Îñîáåííîñòüþ áèáëèîòåêè AMP ÿâëÿåòñÿ òî, ÷òî êëàññ, ïîçâîëÿþùèé îñóùåñòâëÿòü îïåðàöèè ñ âåùåñòâåííûìè ÷èñëàìè âûñîêîé òî÷íîñòè, ÿâëÿåòñÿ êëàññîì-øàáëîíîì, ïàðàìåòðîì êîòîðîãî ÿâëÿåòñÿ öåëîå ÷èñëî, çàäàþùåå òî÷íîñòü õðàíÿùåãîñÿ çíà÷åíèÿ. Òàêèì îáðàçîì, òî÷íîñòü, ñ êîòîðîé îñóùåñòâëÿþòñÿ âû÷èñëåíèÿ, ñòàíîâèòñÿ èçâåñòíà åùž íà ýòàïå êîìïèëÿöèè - ïðè ïàðàìåòðèçàöèè øàáëîíà, è íå ìîæåò áûòü èçìåíåíà â õîäå âûïîëíåíèÿ ïðîãðàììû. Ýòî ñóùåñòâåííîå îãðàíè÷åíèå ôóíêöèîíàëüíîñòè áèáëèîòåêè áûëî ââåäåíî ñîçíàòåëüíî. Ïðè÷èíîé ÿâëÿåòñÿ òî, ÷òî îñíîâíîå íàçíà÷åíèå áèáëèîòåêè AMP - ïðèìåíåíèå â ðàìêàõ ïðîåêòà ALGLIB.  ïðîåêòå ALGLIB áèáëèîòåêà AMP èñïîëüçóåòñÿ ïðîãðàììàìè, ÿâëÿþùèìèñÿ ðåçóëüòàòîì ðàáîòû àâòîìàòè÷åñêîãî òðàíñëÿòîðà. Ãåíåðèðóåìûé òðàíñëÿòîðîì êîä íå ñïîñîáåí ðàáîòàòü ñ âåùåñòâåííûìè ÷èñëàìè, ÷üÿ òî÷íîñòü ìåíÿåòñÿ äèíàìè÷åñêè, ïîñêîëüêó ïðè ýòîì âîçíèêàåò ðÿä ïðîáëåì (íàïðèìåð, êàêóþ òî÷íîñòü ñëåäóåò èñïîëüçîâàòü äëÿ ïðîìåæóòî÷íûõ ðåçóëüòàòîâ, åñëè îäíè ýëåìåíòû ìàòðèöû çàäàíû ñ òî÷íîñòüþ 128 áèò, à äðóãèå - ñ òî÷íîñòüþ 256 áèò). Ïî ýòîé ïðè÷èíå áûëî ðåøåíî ââåñòè âûøåóêàçàííîå îãðàíè÷åíèå.
    8080</p>
    8181
     
    128128        ~ampf();
    129129
    130         ampf ();       
     130        ampf ();
    131131        ampf (<b>long double</b> v);
    132132        ampf (<b>double</b> v);
     
    142142        ampf (<b>const</b> std::string &amp;s);
    143143        ampf (<b>const char</b> *s);
    144        
     144
    145145        ampf(<b>const</b> ampf&amp; r);
    146146        <b>template</b>&lt;<b>unsigned int</b> Precision2&gt;
     
    163163        <b>template</b>&lt;<b>unsigned int</b> Precision2&gt;
    164164        ampf&amp; <b>operator</b>= (<b>const</b> ampf&lt;Precision2&gt;&amp; r);
    165        
     165
    166166        <b>template</b>&lt;<b>class</b> T&gt;
    167167        ampf&amp; <b>operator</b>+=(<b>const</b> T&amp; v);
     
    172172        <b>template</b>&lt;class T&gt;
    173173        ampf&amp; <b>operator</b>/=(<b>const</b> T&amp; v);
    174        
     174
    175175        mpfr_srcptr getReadPtr() <b>const</b>;
    176176        mpfr_ptr getWritePtr();
    177        
     177
    178178        <b>bool</b> isFiniteNumber() <b>const</b>;
    179179        <b>bool</b> isPositiveNumber() <b>const</b>;
     
    185185        std::string toHex() <b>const</b>;
    186186        std::string toDec() <b>const</b>;
    187        
     187
    188188        <b>static const</b> ampf getUlpOf(<b>const</b> ampf &amp;x);
    189189        <b>static const</b> ampf getUlp();
     
    496496Ýòà ôóíêöèÿ âîçâðàùàåò àðêòàíãåíñ ÷èñëà, ðàâíîãî îòíîøåíèþ àðãóìåíòîâ <code>y/x</code>. Ôóíêöèÿ âîçâðàùàåò êîððåêòíûé ðåçóëüòàò, äàæå åñëè <code>x</code> ðàâíî <code>0</code>.
    497497</p>
    498    
     498
    499499<p>
    500500<span class=func>
  • Singular/svd/libs/ap.cpp

    r3803c6 raad4ca4  
    104104    yabs = fabs(z.y);
    105105    w = xabs>yabs ? xabs : yabs;
    106     v = xabs<yabs ? xabs : yabs; 
     106    v = xabs<yabs ? xabs : yabs;
    107107    if( v==0 )
    108108        return w;
  • Singular/svd/libs/ap.english.html

    r3803c6 raad4ca4  
    142142
    143143<p align=justify>
    144 Classes of the standard library allow operations with matrixes and vectors (one-dimensional and two-dimensional arrays) of variable size and with variable numeration of elements, that is, the array numeration can start at any number, end at any number and change dynamically. Because the array classes are templates, the arrays of the same dimension have the same set of member functions. And as the member functions of arrays with different dimensions differ only by the number of arguments, there is little difference between two-dimensional and one-dimenstional arrays. 
     144Classes of the standard library allow operations with matrixes and vectors (one-dimensional and two-dimensional arrays) of variable size and with variable numeration of elements, that is, the array numeration can start at any number, end at any number and change dynamically. Because the array classes are templates, the arrays of the same dimension have the same set of member functions. And as the member functions of arrays with different dimensions differ only by the number of arguments, there is little difference between two-dimensional and one-dimenstional arrays.
    145145</p>
    146146
     
    154154
    155155<p align=justify>
    156 To address the array elements, an overloaded <code:>operator()</code:> is used. That is, the code addressing the element of array <code:>a</code:> with indexes <code:>a(i,j,k)</code:> will look like <code:>a(i,j,k)</code:>. Below is given an example of factorial array calculation, illustrating the work with arrays. 
     156To address the array elements, an overloaded <code:>operator()</code:> is used. That is, the code addressing the element of array <code:>a</code:> with indexes <code:>a(i,j,k)</code:> will look like <code:>a(i,j,k)</code:>. Below is given an example of factorial array calculation, illustrating the work with arrays.
    157157</p>
    158158
     
    201201
    202202<p align=justify>
    203 <span class=func>T&amp; operator()(<b>int</b> i)</span><br> Addressing the array element number i 
     203<span class=func>T&amp; operator()(<b>int</b> i)</span><br> Addressing the array element number i
    204204</p>
    205205
     
    213213
    214214<p align=justify>
    215 <span class=func>T* getcontent()</span><br> Gets pointer to the array. The data pointed by the returned pointer can be changed, and the array content will be changed as well. 
     215<span class=func>T* getcontent()</span><br> Gets pointer to the array. The data pointed by the returned pointer can be changed, and the array content will be changed as well.
    216216</p>
    217217
     
    225225
    226226<p align=justify>
    227 <span class=func>const_raw_vector&lt;T&gt; getvector(<b>int</b> iStart, <b>int</b> iEnd) <b>const</b></span><br> The method is used by the basic subroutines of linear algebra to get access to the internal memory of the array. The method returns an object, holding the pointer to a vector part (starting from the element with iStart index value and finishing with iEnd index value). If iEnd&lt;iStart, then an empty vector is considered to be set. The returned object is for read only. 
     227<span class=func>const_raw_vector&lt;T&gt; getvector(<b>int</b> iStart, <b>int</b> iEnd) <b>const</b></span><br> The method is used by the basic subroutines of linear algebra to get access to the internal memory of the array. The method returns an object, holding the pointer to a vector part (starting from the element with iStart index value and finishing with iEnd index value). If iEnd&lt;iStart, then an empty vector is considered to be set. The returned object is for read only.
    228228</p>
    229229
     
    273273
    274274<p align=justify>
    275 <span class=func>T* getcontent()</span><br> Gets pointer to the array. The data pointed by the returned pointer can be changed, and the array content will be changed as well. 
     275<span class=func>T* getcontent()</span><br> Gets pointer to the array. The data pointed by the returned pointer can be changed, and the array content will be changed as well.
    276276</p>
    277277
  • Singular/svd/libs/ap.h

    r3803c6 raad4ca4  
    2828
    2929/********************************************************************
    30 This symbol is used for debugging. Do not define it and do not remove 
    31 comments. 
     30This symbol is used for debugging. Do not define it and do not remove
     31comments.
    3232********************************************************************/
    3333//#define UNSAFE_MEM_COPY
     
    124124
    125125/********************************************************************
    126 Template defining vector in memory. It is used by the basic 
     126Template defining vector in memory. It is used by the basic
    127127subroutines of linear algebra.
    128128
    129 Vector consists of Length elements of type T, starting from an element, 
    130 which Data is pointed to. Interval between adjacent elements equals 
     129Vector consists of Length elements of type T, starting from an element,
     130which Data is pointed to. Interval between adjacent elements equals
    131131the value of Step.
    132132
     
    158158It is used by the basic subroutines of linear algebra.
    159159
    160 Vector consists of Length elements of type T, starting from an element, 
    161 which Data is pointed to. Interval between adjacent elements equals 
     160Vector consists of Length elements of type T, starting from an element,
     161which Data is pointed to. Interval between adjacent elements equals
    162162the value of Step.
    163163
     
    688688    };
    689689
    690    
     690
    691691    const template_1d_array& operator=(const template_1d_array &rhs)
    692692    {
     
    714714    };
    715715
    716    
     716
    717717    const T& operator()(int i) const
    718718    {
     
    723723    };
    724724
    725    
     725
    726726    T& operator()(int i)
    727727    {
     
    732732    };
    733733
    734    
     734
    735735    void setbounds( int iLow, int iHigh )
    736736    {
     
    743743    };
    744744
    745    
     745
    746746    void setcontent( int iLow, int iHigh, const T *pContent )
    747747    {
     
    751751    };
    752752
    753    
     753
    754754    T* getcontent()
    755755    {
     
    762762    };
    763763
    764    
     764
    765765    int getlowbound(int iBoundNum = 0) const
    766766    {
     
    768768    };
    769769
    770    
     770
    771771    int gethighbound(int iBoundNum = 0) const
    772772    {
     
    782782    };
    783783
    784    
     784
    785785    const_raw_vector<T> getvector(int iStart, int iEnd) const
    786786    {
  • Singular/svd/libs/ap.russian.html

    r3803c6 raad4ca4  
    184184
    185185<p align=justify>
    186 Äëÿ îáðàùåíèÿ ê ýëåìåíòàì ìàññèâà èñïîëüçóåòñÿ ïåðåãðóæåííûé <code:>operator()</code:>. Ò.å. êîä, îáðàùàþùèéñÿ ê ýëåìåíòó ìàññèâà <code:>a</code:> ñ èíäåêñàìè <code:>i, j, k</code:> áóäåò âûãëÿäåòü êàê <code:>a(i,j,k)</code:>. Íèæå ïðèâåäåí ïðèìåð âû÷èñëåíèÿ ìàññèâà ôàêòîðèàëîâ, èëëþñòðèðóþùèé ðàáîòó ñ ìàññèâàìè. 
     186Äëÿ îáðàùåíèÿ ê ýëåìåíòàì ìàññèâà èñïîëüçóåòñÿ ïåðåãðóæåííûé <code:>operator()</code:>. Ò.å. êîä, îáðàùàþùèéñÿ ê ýëåìåíòó ìàññèâà <code:>a</code:> ñ èíäåêñàìè <code:>i, j, k</code:> áóäåò âûãëÿäåòü êàê <code:>a(i,j,k)</code:>. Íèæå ïðèâåäåí ïðèìåð âû÷èñëåíèÿ ìàññèâà ôàêòîðèàëîâ, èëëþñòðèðóþùèé ðàáîòó ñ ìàññèâàìè.
    187187</p>
    188188
  • Singular/svd/lq.h

    r3803c6 raad4ca4  
    133133        for(i=0; i<=k-1; i++)
    134134        {
    135            
     135
    136136            //
    137137            // Generate elementary reflector H(i) to annihilate A(i,i+1:n-1)
     
    144144            if( i<n )
    145145            {
    146                
     146
    147147                //
    148148                // Apply H(i) to A(i+1:m,i:n) from the right
     
    195195            return;
    196196        }
    197        
     197
    198198        //
    199199        // init
     
    218218            }
    219219        }
    220        
     220
    221221        //
    222222        // unpack Q
     
    224224        for(i=k-1; i>=0; i--)
    225225        {
    226            
     226
    227227            //
    228228            // Apply H(i)
     
    306306        t.setbounds(1, n);
    307307        tau.setbounds(1, minmn);
    308        
     308
    309309        //
    310310        // Test the input arguments
     
    313313        for(i=1; i<=k; i++)
    314314        {
    315            
     315
    316316            //
    317317            // Generate elementary reflector H(i) to annihilate A(i,i+1:n)
     
    325325            if( i<n )
    326326            {
    327                
     327
    328328                //
    329329                // Apply H(i) to A(i+1:m,i:n) from the right
     
    361361            return;
    362362        }
    363        
     363
    364364        //
    365365        // init
     
    384384            }
    385385        }
    386        
     386
    387387        //
    388388        // unpack Q
     
    390390        for(i=k; i>=1; i--)
    391391        {
    392            
     392
    393393            //
    394394            // Apply H(i)
     
    423423        q.setbounds(1, n, 1, n);
    424424        l.setbounds(1, m, 1, n);
    425        
     425
    426426        //
    427427        // LQDecomposition
    428428        //
    429429        lqdecomposition<Precision>(a, m, n, tau);
    430        
     430
    431431        //
    432432        // L
     
    446446            }
    447447        }
    448        
     448
    449449        //
    450450        // Q
  • Singular/svd/makeheader

    r3803c6 raad4ca4  
    1818
    1919To include a header file into the generated header file
    20 (= <outfile>) use the two lines 
     20(= <outfile>) use the two lines
    2121
    2222/*MAKEHEADER*/
     
    7373    exit 1
    7474fi
    75    
     75
    7676# try to create $outfile if it does not exist
    7777if test -w "$outfile" || cp /dev/null "$outfile" > /dev/null 2> /dev/null; then
  • Singular/svd/mkinstalldirs

    r3803c6 raad4ca4  
    88errstatus=0
    99
    10 for file in ${1+"$@"} ; do 
     10for file in ${1+"$@"} ; do
    1111   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
    1212   shift
  • Singular/svd/qr.h

    r3803c6 raad4ca4  
    142142        t.setbounds(1, m);
    143143        tau.setbounds(0, minmn-1);
    144        
     144
    145145        //
    146146        // Test the input arguments
     
    149149        for(i=0; i<=k-1; i++)
    150150        {
    151            
     151
    152152            //
    153153            // Generate elementary reflector H(i) to annihilate A(i+1:m,i)
     
    160160            if( i<n )
    161161            {
    162                
     162
    163163                //
    164164                // Apply H(i) to A(i:m-1,i+1:n-1) from the left
     
    211211            return;
    212212        }
    213        
     213
    214214        //
    215215        // init
     
    234234            }
    235235        }
    236        
     236
    237237        //
    238238        // unpack Q
     
    240240        for(i=k-1; i>=0; i--)
    241241        {
    242            
     242
    243243            //
    244244            // Apply H(i)
     
    319319        t.setbounds(1, m);
    320320        tau.setbounds(1, minmn);
    321        
     321
    322322        //
    323323        // Test the input arguments
     
    326326        for(i=1; i<=k; i++)
    327327        {
    328            
     328
    329329            //
    330330            // Generate elementary reflector H(i) to annihilate A(i+1:m,i)
     
    338338            if( i<n )
    339339            {
    340                
     340
    341341                //
    342342                // Apply H(i) to A(i:m,i+1:n) from the left
     
    373373            return;
    374374        }
    375        
     375
    376376        //
    377377        // init
     
    396396            }
    397397        }
    398        
     398
    399399        //
    400400        // unpack Q
     
    402402        for(i=k; i>=1; i--)
    403403        {
    404            
     404
    405405            //
    406406            // Apply H(i)
     
    440440        q.setbounds(1, m, 1, m);
    441441        r.setbounds(1, m, 1, n);
    442        
     442
    443443        //
    444444        // QRDecomposition
    445445        //
    446446        qrdecomposition<Precision>(a, m, n, tau);
    447        
     447
    448448        //
    449449        // R
     
    461461            ap::vmove(r.getrow(i, i, n), a.getrow(i, i, n));
    462462        }
    463        
     463
    464464        //
    465465        // Q
  • Singular/svd/reflections.h

    r3803c6 raad4ca4  
    122122
    123123
    124        
     124
    125125        //
    126126        // Executable Statements ..
     
    131131            return;
    132132        }
    133        
     133
    134134        //
    135135        // XNORM = DNRM2( N-1, X, INCX )
     
    152152        if( xnorm==0 )
    153153        {
    154            
     154
    155155            //
    156156            // H  =  I
     
    159159            return;
    160160        }
    161        
     161
    162162        //
    163163        // general case
     
    223223            return;
    224224        }
    225        
     225
    226226        //
    227227        // w := C' * v
     
    237237            ap::vadd(work.getvector(n1, n2), c.getrow(i, n1, n2), t);
    238238        }
    239        
     239
    240240        //
    241241        // C := C - tau * v * w'
     
    296296            return;
    297297        }
    298        
     298
    299299        //
    300300        // w := C * v
     
    306306            work(i) = t;
    307307        }
    308        
     308
    309309        //
    310310        // C := C - w * v'
  • Singular/svd/rotations.h

    r3803c6 raad4ca4  
    119119            return;
    120120        }
    121        
     121
    122122        //
    123123        // Form  P * A
     
    127127            if( n1!=n2 )
    128128            {
    129                
     129
    130130                //
    131131                // Common case: N1<>N2
     
    148148            else
    149149            {
    150                
     150
    151151                //
    152152                // Special case: N1=N2
     
    169169            if( n1!=n2 )
    170170            {
    171                
     171
    172172                //
    173173                // Common case: N1<>N2
     
    190190            else
    191191            {
    192                
     192
    193193                //
    194194                // Special case: N1=N2
     
    253253
    254254
    255        
     255
    256256        //
    257257        // Form A * P'
     
    261261            if( m1!=m2 )
    262262            {
    263                
     263
    264264                //
    265265                // Common case: M1<>M2
     
    282282            else
    283283            {
    284                
     284
    285285                //
    286286                // Special case: M1=M2
     
    303303            if( m1!=m2 )
    304304            {
    305                
     305
    306306                //
    307307                // Common case: M1<>M2
     
    324324            else
    325325            {
    326                
     326
    327327                //
    328328                // Special case: M1=M2
  • Singular/svd/tests/testsvdunit.h

    r3803c6 raad4ca4  
    9090        failthreshold = amp::ampf<Precision>("5.0E-3");
    9191        a.setbounds(0, maxmn-1, 0, maxmn-1);
    92        
     92
    9393        //
    9494        // TODO: div by zero fail, convergence fail
     
    9696        for(gpass=1; gpass<=1; gpass++)
    9797        {
    98            
     98
    9999            //
    100100            // zero matrix, several cases
     
    114114                }
    115115            }
    116            
     116
    117117            //
    118118            // Long dense matrix
     
    146146                }
    147147            }
    148            
     148
    149149            //
    150150            // Dense matrices
     
    164164                }
    165165            }
    166            
     166
    167167            //
    168168            // Sparse matrices, very sparse matrices, incredible sparse matrices
     
    184184            }
    185185        }
    186        
     186
    187187        //
    188188        // report
     
    283283
    284284        minmn = ap::minint(m, n);
    285        
     285
    286286        //
    287287        // decomposition error
     
    301301        }
    302302        materr = amp::maximum<Precision>(materr, locerr);
    303        
     303
    304304        //
    305305        // orthogonality error
     
    331331        }
    332332        orterr = amp::maximum<Precision>(orterr, locerr);
    333        
     333
    334334        //
    335335        // values order error
     
    373373
    374374
    375        
     375
    376376        //
    377377        // Main SVD test
     
    384384        }
    385385        getsvderror<Precision>(a, m, n, u, w, vt, materr, orterr, wsorted);
    386        
     386
    387387        //
    388388        // Additional SVD tests
     
    439439            }
    440440        }
    441        
     441
    442442        //
    443443        // update counter
Note: See TracChangeset for help on using the changeset viewer.