Re: Request for comment: follow-up to Summer of Code



beliavsky@xxxxxxx wrote:


> In my earlier message I compared Fortran to C, not C++. I think the
> functionality of Fortran's multidimensional arrays (elemental
> functions, array slices) is more extensive than that of C++, whose
> arrays have the same properties as those of C.

People masochistic enough to work by choice in C++ would usually use
the Boost or Blitz++ multidim arrays, which both make extensive
use of templates and operator overloading to embed multidim-array
little languages into C++:

Boost:
http://www.boost.org/libs/multi_array/doc/user.html

Blitz++:
http://www.oonumerics.org/blitz/manual/blitz02.html#l30

>From Blitz++ example:

#include <blitz/array.h>

using namespace blitz;

int main()
{
Array<float,2> A(3,3), B(3,3), C(3,3);

A = 1, 0, 0,
2, 2, 2,
1, 0, 0;

B = 0, 0, 7,
0, 8, 0,
9, 9, 9;

C = A + B;
cout << "A = " << A << endl
<< "B = " << B << endl
<< "C = " << C << endl;

return 0;
}

As you can see, a bit of a step up from C arrays. I know many C++
programmers don't consider C++ a complete language without Boost.

Fortran 90 or above is still a nicer choice IMHO, really, it makes for
clearer code (to the countless scientists and engineers who know and
"love" fortran) and still integrates better with the vast corpus of
fortran numerics libraries built up over the past decades, but anyway.



.



Relevant Pages

  • Re: best practices for structuring ASCII input
    ... I'm maintaining a number of smallengineering/scientific Fortran ... data consists of a mixture of variables, arrays, ... the input files are not human readable. ...
    (comp.lang.fortran)
  • Re: bivariate interpolation
    ... > interpolated using Akima's Bivariate Interpolation for Smooth Surface ... > rewrite the code form its original Fortran V to much cleaner C. ... > The routine has numerous 2-dimensional arrays that are being accessed ...
    (comp.lang.c)
  • Re: seeking advice for "translate" Fortran code to Java code
    ... redefine a common block as needed for each subroutine. ... Still, Java has no pointers, so I ... Java arrays are always what C would call arrays of pointers ... Fortran intrinsics in Java appropriately. ...
    (comp.lang.fortran)
  • Re: INTERFACE problem
    ... I have an integer at Fortran side, pass it by reference to C function, treat here as pointer, allocate memory and this C-pointer at Fortran side now is an integer which has represents address allocated at C side. ... I did something like this many years ago to allow dynamic allocation ... Then it was converted into a subroutine with the arrays and ... it called the sub by way of Pascal with those "pointers". ...
    (comp.lang.fortran)
  • Re: couple c and fortran 95
    ... I would always put middleware layer at either side of the interface not just ... Fortran by Reference. ... arrays or by passing a pointer from the C side of the interface. ... C strings are null terminated arrays of character; ...
    (comp.lang.fortran)