keffer@blake.acs.washington.edu (Thomas Keffer) (05/05/89)
There has been a lot of discussion on implementing a set of vector and matrix classes in C++, particularly with respect to minimizing temporary variables. I am wondering what implementations exist out there? Keith Gorlen has supplied a fairly complete set of Vector classes as part of his "NIH Class Library" (nee OOPS), but these are overly general for many applications and can be slow because the copy initializer relies on copying all elements. What else? Is this the state of the art? One can think of many useful extensions besides the obvious arithmetic operations (+, *, -, etc.) such as: 1) Classes for specialized types of matricies, such as symmetrical or tridiagonal. These would use "optimized" algorithms for such operations as solving linear sets of equations, etc. 2) A class LU_decomposition? Contains the LU decomposition of a matrix. Would include member functions such as invert(), or solve(). 3) There HAS been some discussion of FFT algorithms (principally from Dr. James Coggins and myself). Any implementations? In particular, what other algorithm servers have been implemented? I have made a start in these three areas by building specialized derived classes on top of the NIH classes. But they can become unwieldy because of all the underlying machinery. I was hoping to do something cleaner and build these specialized operations on top of a leaner set of matrix and vector classes. But, I'm coming to appreciate that for all their bulk and sometimes overgenerality, the NIH classes have the overwhelming advantage that THEY EXIST!!!
jima@hplsla.HP.COM (Jim Adcock) (05/06/89)
#include <complex.h> #include <stream.h> // Fft a double precision complex array x of size (2 to the m) // based on a fortran routine from Oppenheim and Schafer, // though that's not the original source, I don't think. // Even considering its simplicity, this fft does surprisingly well. int fft(complex* x, unsigned m) { complex u, w, t; unsigned n = 1 << m; unsigned nv2 = n >> 1; unsigned nm1 = n - 1; unsigned j = 0; for (unsigned i = 0; i < nm1; ++i) { if (i < j) {t = x[j]; x[j] = x[i]; x[i] = t;} unsigned k = nv2; while ((k-1) < j) {j -= k; k >> 1;} j += k; } for (unsigned l = 1; l <= m; ++l) { unsigned le = 1 << l; unsigned le1 = le >> 1; complex u(1.0, 0.0); complex w(cos(M_PI/double(le1)),sin(M_PI/double(le1))); for (j = 0; j < le1; ++j) { for (i = j; i < n; i += le) { unsigned ip = i + le1; t = x[ip] * u; x[ip] = x[i] - t; x[i] += t; } u *= w; } } return m; } #define SZ 8 #define LGSZ 3 main() { complex x[SZ]; for (unsigned i = 0; i < SZ; ++i) { for (unsigned j = 0; j < SZ; ++j) x[j] = 0.0; x[i] = 1.0; fft(x, LGSZ); for (j = 0; j < SZ; ++j) cout << x[j] << " "; cout << "\n"; } }
jima@hplsla.HP.COM (Jim Adcock) (05/23/89)
Regards the original question -- vector and math classes, beside Gorlan's stuff, I believe there is a Gnu matrix class in the works, also I just saw in Dr. D's June 89 pg 132 an ad for "M++" Matrix Class Software, $495 [thats $495. not $4.95 :-] from Ansys Software 206-228-3170 I know nothing about the quality of these two matrix classes. I am also personally implementing a "tiny" fixed two element vector and two-by-two matrix set of classes for 2D graphics work and the like. Plan to do a 3D version. Let me know if these could really be of use to someone.
jima@hplsla.HP.COM (Jim Adcock) (06/13/89)
> I am also personally implementing a "tiny" fixed two element > vector and two-by-two matrix set of classes for 2D graphics > work and the like. Plan to do a 3D version. Let me know > if these could really be of use to someone. Sorry, me and my computer conspired to spindle some mail requests for this. Please ask again if you still want these. I have them in pretty good shape by now: 2x2 and 3x3 matrices [and vectors.]
Roy.Browning@f506.n106.z1.fidonet.org (Roy Browning) (06/18/89)
> From: jima@hplsla.HP.COM (Jim Adcock) > > I am also personally implementing a "tiny" fixed two element > > vector and two-by-two matrix set of classes for 2D graphics > > work and the like. Plan to do a 3D version. Let me know > > if these could really be of use to someone. > > Sorry, me and my computer conspired to spindle some mail requests for > this. > Please ask again if you still want these. I have them in pretty good > shape > by now: 2x2 and 3x3 matrices [and vectors.] > v Jim: I have been trying to collect C++ source code for over six months with little to no success. Personally I learn a language by studying working code. And I'll make it available to one and all who call my system. However there is a problem. I run a FidoNet BBSystem and don't use UUCP. If you can upload the source to a local public BBSystem Board I would be more than happy to make the call to pick it up. A FidoNet Board that allowed File_Requests would be excellent. Thanks for making your effor ts accessable. I want the code but how do I get it <grin>, Roy Browning
jima@hplsla.HP.COM (Jim Adcock) (06/24/89)
I haven't been able to figure out a mail path to fox. Try sending me some mail with an explicet mail path I can try -- if fox still wants this.
Roy.Browning@f506.n106.z1.fidonet.org (Roy Browning) (07/22/89)
> From: jima@hplsla.HP.COM (Jim Adcock) > > I am also personally implementing a "tiny" fixed two element > > vector and two-by-two matrix set of classes for 2D graphics > > work and the like. Plan to do a 3D version. Let me know > > if these could really be of use to someone. > > Sorry, me and my computer conspired to spindle some mail requests for > this. > Please ask again if you still want these. I have them in pretty good > shape > by now: 2x2 and 3x3 matrices [and vectors.] > v Jim: I have been trying to collect C++ source code for over six months with little to no success. Personally I learn a language by studying working code. And I'll make it available to one and all who call my system. However there is a problem. I run a FidoNet BBSystem and don't use UUCP. If you can upload the source to a local public BBSystem Board I would be more than happy to make the call to pick it up. A FidoNet Board that allowed File_Requests would be excellent. Thanks for making your effor ts accessable. I want the code but how do I get it <grin>, Roy Browning
jima@hplsla.HP.COM (Jim Adcock) (08/03/89)
> > I want the code but how do I get it <grin>, > > Roy Browning Hate to burn up bandwidth on this, but.... I've tried to reach Roy and my mail bounces. I'd be happy to post my stuff to a public place if someone tells me how to put it there, and if it takes me a reasonably finite effort to do so. Please forward this message to Roy, if you know him. I've been responding typically in less than a day to people's request for software .... if you don't here from me quickly, I'm probably having a hard time figuring out a valid way to mail to you.... But at the same time, be aware distributing software is not my official job function -- I'm just trying to help out fellow C++'ers where to do so isn't going to cost HP much.
SRWMRBD@windy.dsir.govt.nz (ROBERT) (08/07/89)
>I've been responding typically in less than a day to people's request for >software .... if you don't hear from me quickly, I'm probably having a hard >time figuring out a valid way to mail to you.... 15 people requested copies of my beginnings of a vector/matrix package - so there is interest in such things out there. I have replied to these more or less at once so if you haven't heard from me then either your message or my reply was lost in the mail.