## digitalmars.D - Easy vectorization

• Lionello Lunesu (14/14) Jun 07 2005 Hey, just an idea for 1.0:
• zwang (3/24) Jun 07 2005 Looks ambiguous. What if there exists an overloaded function that takes...
• James Dunne (7/31) Jun 07 2005 Now we're just getting lazy =P. Yes, it is ambiguous for the exact reas...
• Lionello Lunesu (13/13) Jun 08 2005 | Now we're just getting lazy =P. Yes, it is ambiguous for the exact re...
• Lionello Lunesu (6/6) Jun 08 2005 | Looks ambiguous. What if there exists an overloaded function that tak...
• =?iso-8859-1?q?Knud_S=F8rensen?= (4/23) Jun 07 2005 How is that better than the old suggestions for vectorization ?
• Lionello Lunesu (3/3) Jun 08 2005 | How is that better than the old suggestions for vectorization ?
"Lionello Lunesu" <lio lunesu.removethis.com> writes:
```Hey, just an idea for 1.0:

What if the compiler would generate multiple calls to a function if you pass
an array of values (instead of a single value)?

Examples:

float[] a;
sin(a) // would generate a "foreach"
float[] b;
atan2(a,b) // would generate a single "foreach" (will throw/assert if sizes
differ)
atan2(4,a) // same as before, but now with a constant for the first
parameter.

Seems easy enough to do, just an extended type-check. The type of the array
should still match, of course.

L.
```
Jun 07 2005
zwang <nehzgnaw gmail.com> writes:
```Lionello Lunesu wrote:
Hey, just an idea for 1.0:

What if the compiler would generate multiple calls to a function if you pass
an array of values (instead of a single value)?

Examples:

float[] a;
sin(a) // would generate a "foreach"
float[] b;
atan2(a,b) // would generate a single "foreach" (will throw/assert if sizes
differ)
atan2(4,a) // same as before, but now with a constant for the first
parameter.

Seems easy enough to do, just an extended type-check. The type of the array
should still match, of course.

L.

Looks ambiguous.  What if there exists an overloaded function that takes
an array of values?
```
Jun 07 2005
James Dunne <james.jdunne gmail.com> writes:
```In article <d83vof\$27cc\$1 digitaldaemon.com>, zwang says...
Lionello Lunesu wrote:
Hey, just an idea for 1.0:

What if the compiler would generate multiple calls to a function if you pass
an array of values (instead of a single value)?

Examples:

float[] a;
sin(a) // would generate a "foreach"
float[] b;
atan2(a,b) // would generate a single "foreach" (will throw/assert if sizes
differ)
atan2(4,a) // same as before, but now with a constant for the first
parameter.

Seems easy enough to do, just an extended type-check. The type of the array
should still match, of course.

L.

Looks ambiguous.  What if there exists an overloaded function that takes
an array of values?

Now we're just getting lazy =P.  Yes, it is ambiguous for the exact reason
specified.

Just for argument's sake, where do you store your return values from sin(a)
where (float[] a) if it's implicitly converted into a foreach loop?

Regards,
James Dunne
```
Jun 07 2005
"Lionello Lunesu" <lio lunesu.removethis.com> writes:
```| Now we're just getting lazy =P.  Yes, it is ambiguous for the exact reason
| specified.

If we weren't we wouldn't have invented in the PCs and programming languages
in the first place :-)

| Just for argument's sake, where do you store your return values from
sin(a)
| where (float[] a) if it's implicitly converted into a foreach loop?

Well, sin is maybe a strange example, but I guess the call to sin with an
array results in an array with the return values. Seems easy enough to
implement.

Maybe it's tricky though, a "sin(a)" can be very slow and might get easily
overlooked for a bottleneck.

L.
```
Jun 08 2005
"Lionello Lunesu" <lio lunesu.removethis.com> writes:
```| Looks ambiguous.  What if there exists an overloaded function that takes
| an array of values?

You solve that the same way similar problems are already solved:

If you have a func(int) and call it with a short, it'll convert the short to
an int, but if you also have func(short) then that's the one being called.

L.
```
Jun 08 2005
=?iso-8859-1?q?Knud_S=F8rensen?= <12tkvvb02 sneakemail.com> writes:
```How is that better than the old suggestions for vectorization ?

http://all-technology.com/eigenpolls/dwishlist/index.php?it=10

On Tue, 07 Jun 2005 13:43:20 +0300, Lionello Lunesu wrote:

Hey, just an idea for 1.0:

What if the compiler would generate multiple calls to a function if you pass
an array of values (instead of a single value)?

Examples:

float[] a;
sin(a) // would generate a "foreach"
float[] b;
atan2(a,b) // would generate a single "foreach" (will throw/assert if sizes
differ)
atan2(4,a) // same as before, but now with a constant for the first
parameter.

Seems easy enough to do, just an extended type-check. The type of the array
should still match, of course.

L.

```
Jun 07 2005
"Lionello Lunesu" <lio lunesu.removethis.com> writes:
```| How is that better than the old suggestions for vectorization ?

Uh... Syntax?

L.
```
Jun 08 2005