Google apps
Main menu

Post a Comment On: Charlie's Second Blog

"How to compute "y = a * x + y""

2 Comments -

1 – 2 of 2
Anonymous Anonymous said...

Excuse me, but if you found this:

void func(float x[N], float y[N], float a) {
for(size_t i = 0; i < N; ++i) {
y[i] += a * x[i];
}
}

or this :

cblas_daxpy(N, a, x, 1, y, 1);

"over complicated", compared to this:

subroutine func(x, y, a)
implicit none
REAL, dimension(:), intent(in) :: x
REAL, dimension(:), intent(inout) :: y
REAL, intent(in) :: a

y = a * x + y

end subroutine func

...

We really don't think the same !!! Just make the sum of letters of all functions !

3 February 2009 at 06:25

Blogger Guillaume Chéreau said...

Ok if you count the sum of letters in this simple example the fortran version is not the best, but that is only because the header part of the function is longer, the core itself is very simple : y = a * x + y

Now if we had a serie of similar operations, fortran would then look better.

Anyway, i want to express things as a vector operation, that is the point, and c won't let me do this in a "beautiful" way.

3 February 2009 at 07:39

You can use some HTML tags, such as <b>, <i>, <a>

You will be asked to sign in after submitting your comment.
Please prove you're not a robot