From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.0 required=3.0 tests=BAYES_40,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:622a:2281:b0:3b6:326f:fe37 with SMTP id ay1-20020a05622a228100b003b6326ffe37mr1162169qtb.57.1674640257391; Wed, 25 Jan 2023 01:50:57 -0800 (PST) X-Received: by 2002:a9d:6f05:0:b0:686:4b6f:78a8 with SMTP id n5-20020a9d6f05000000b006864b6f78a8mr1504676otq.291.1674640257153; Wed, 25 Jan 2023 01:50:57 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 25 Jan 2023 01:50:56 -0800 (PST) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=157.143.56.236; posting-account=Wbe3fAoAAAALa8UT9MWTy6mw2ahlRJms NNTP-Posting-Host: 157.143.56.236 References: <9c7cccd9-733f-49a8-b482-087ccb14b58dn@googlegroups.com> <62954fe7-8f83-40ad-823f-ef628c43c544n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Real_Arrays on heap with overloaded operators and clean syntax From: Jim Paloander Injection-Date: Wed, 25 Jan 2023 09:50:57 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:64877 List-Id: Dear Gautier, thank you for the draft. Indeed something like that would be great possibly= without polynomials or rational numbers etc. You just need doubles and/or = floats and complex numbers. Sparse matrices are another animal, and once ad= opted they are another dimension of complexity. This is because apart from = the triplet format which is easily expandable, one may also need to convert= the triplet to CSR and there multiple entries with same row and column ind= ex need first to be summed so we have a single entry (i, j, value) for each= (i, j) before converting to CSR. So I mean, one would like to build a libr= ary then and I am not so sure how easy would be to hardcode this library so= that operations on matrices/vectors are as efficient as in Fortran. For De= nse matrices it may still be possible to support mathematical expressions w= ithout introducing temporary objects. But if you also bring sparse into the= game then? (alpha,beta,gamma scalars, while x,y,z,w vectors, A, B_sparse matrices) does this have a chance to be executed without temporaries? y :=3D alpha*x + beta*A*x + gamma*B_sparse*(z-w) this has a chance to be executed without temporaries Fortran already does i= t. y :=3D alpha*x + beta*A*x I would create a SparseMatrix library and break the statement above in 2 y1 :=3D B_sparse*(z-w) y :=3D alpha*x + beta*A*x + gamma*y1; I could survive with that. The problem dear Gautier is the temporary object= s in such libraries. Very correctly J.P.Rosen suggested BLAS. The problem i= s that for simple vector operations (BLAS1) there is no speedup at all and = the operations of BLAS1 cannot be executed for the whole expression, just i= n an `axpy (a*x+y)` manner one by one. This would require transversal of t= he arrays many times in a long expression involving vectors as (y :=3D x1 += x2*alpha + beta*(x3-gamma*x4) + alpha*beta*(x1-x2)). For BLAS2 operations = (matrix times vector) you may see a performance gain using BLAS but for lar= ge matrices, very large. Where you definitely see such a performance gain i= s for BLAS3 and there we definitely need something like that.=20 This discussion started about techniques to avoid generation of temporaries= . Even when you manipulate complex numbers you introduce temporaries. I nee= d to come back to you guys with some number to understand the problem bette= r. I will be back with these numbers. But until then, please let me know, d= o you feel that there is a need of a performance uplifting and mathematics = enabling ADA library which is not Real_Arrays or Containers, but a real Mat= h library allowing Real and Complex math manipulation and integrating possi= bly some Lapack routines as Real_Arrays do at the moment?