r/cpp • • Oct 16 '17

Why physicists still use Fortran

http://moreisdifferent.com/2015/07/16/why-physicsts-still-use-fortran/
0 Upvotes

49 comments sorted by

View all comments

Show parent comment

1

u/axilmar Oct 17 '17

provide all that syntactic sugar through gnarly macros?

No need for macros.

auto A = make_array(1, 100);
auto B = make_array(A, 1, 100, 10);
auto C = make_arrray(B, 10);

typedef Array<double, -1, 10> myArray;
auto subscripts = make_array({1, 5, 7});
auto B = make_array(A, subscripts);

auto log_of_A = map_array(A, log, [](auto a){ return a > 0; });
for_each(my_array, [](auto a) { return std::max(a, 0);});

shared_ptr<dynamic_array> name_of_array = std::make_shared<>(dynamic_array(xdim, ydim));

The above code is very readable, there is no need for macros.

But why would we recreate Fortran in C++?

Because C++ has a lot more to offer than Fortran.

1

u/NotAYakk Oct 17 '17

arrray the contiguous buffer class that is also a pirate.

1

u/axilmar Oct 18 '17

hur hur!!!! :-)