Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #50126 > unrolled thread
| Started by | Ron Aaron <rambamist@gmail.com> |
|---|---|
| First post | 2016-08-15 07:19 +0300 |
| Last post | 2016-08-18 17:19 +0000 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.forth
Dot product Ron Aaron <rambamist@gmail.com> - 2016-08-15 07:19 +0300
Re: Dot product lawrencedo99@gmail.com - 2016-08-14 21:57 -0700
Re: Dot product Ron Aaron <rambamist@gmail.com> - 2016-08-15 08:33 +0300
Re: Dot product lehs <skydda.barnen@gmail.com> - 2016-08-14 23:43 -0700
Re: Dot product Ron Aaron <rambamist@gmail.com> - 2016-08-15 10:01 +0300
Re: Dot product "WJ" <w_a_x_man@yahoo.com> - 2016-08-18 17:19 +0000
| From | Ron Aaron <rambamist@gmail.com> |
|---|---|
| Date | 2016-08-15 07:19 +0300 |
| Subject | Dot product |
| Message-ID | <norft6$sva$1@dont-email.me> |
From RosettaCode: http://8th-dev.com/forum/index.php/topic,1050.0.html [1,3,-5] [4,-2,1] ' n:* ' n:+ a:dot . cr outputs 3 The a:dot word is a generalized dot-product of two similarly-sized arrays. So it can do a great deal more than a simple math dot-product.
[toc] | [next] | [standalone]
| From | lawrencedo99@gmail.com |
|---|---|
| Date | 2016-08-14 21:57 -0700 |
| Message-ID | <e34b433e-2b57-4ab6-93a1-3797692fb760@googlegroups.com> |
| In reply to | #50126 |
On Monday, August 15, 2016 at 4:19:51 PM UTC+12, Ron Aaron wrote: > The a:dot word is a generalized dot-product of two similarly-sized > arrays. So it can do a great deal more than a simple math dot-product. Does it work on general tensors?
[toc] | [prev] | [next] | [standalone]
| From | Ron Aaron <rambamist@gmail.com> |
|---|---|
| Date | 2016-08-15 08:33 +0300 |
| Message-ID | <nork7h$6k5$1@dont-email.me> |
| In reply to | #50127 |
On 08/15/2016 07:57, lawrencedo99@gmail.com wrote: > On Monday, August 15, 2016 at 4:19:51 PM UTC+12, Ron Aaron wrote: >> The a:dot word is a generalized dot-product of two similarly-sized >> arrays. So it can do a great deal more than a simple math dot-product. > > Does it work on general tensors? > It works on arrays. An array can contain any other data type; tensors are not built-in, but you can create them if you want.
[toc] | [prev] | [next] | [standalone]
| From | lehs <skydda.barnen@gmail.com> |
|---|---|
| Date | 2016-08-14 23:43 -0700 |
| Message-ID | <2906a9e9-5e8b-4563-92ec-034f8dcc3de1@googlegroups.com> |
| In reply to | #50126 |
Den måndag 15 augusti 2016 kl. 06:19:51 UTC+2 skrev Ron Aaron: > From RosettaCode: > > http://8th-dev.com/forum/index.php/topic,1050.0.html > > [1,3,-5] [4,-2,1] ' n:* ' n:+ a:dot . cr > > outputs 3 > > The a:dot word is a generalized dot-product of two similarly-sized > arrays. So it can do a great deal more than a simple math dot-product. isn't the dot product of [1,3,-5] and [4,-2,1] =1*4+3*(-2)+(-5)*1=-7?
[toc] | [prev] | [next] | [standalone]
| From | Ron Aaron <rambamist@gmail.com> |
|---|---|
| Date | 2016-08-15 10:01 +0300 |
| Message-ID | <norpch$igv$1@dont-email.me> |
| In reply to | #50130 |
On 08/15/2016 09:43, lehs wrote: > Den måndag 15 augusti 2016 kl. 06:19:51 UTC+2 skrev Ron Aaron: >> From RosettaCode: >> >> http://8th-dev.com/forum/index.php/topic,1050.0.html >> >> [1,3,-5] [4,-2,1] ' n:* ' n:+ a:dot . cr >> >> outputs 3 >> >> The a:dot word is a generalized dot-product of two similarly-sized >> arrays. So it can do a great deal more than a simple math dot-product. > > isn't the dot product of [1,3,-5] and [4,-2,1] =1*4+3*(-2)+(-5)*1=-7? > Yes. The last '1' s/b a '-1'. Sorry :o
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2016-08-18 17:19 +0000 |
| Message-ID | <np4qm3$8cn$1@dont-email.me> |
| In reply to | #50126 |
Ron Aaron wrote:
> From RosettaCode:
>
> http://8th-dev.com/forum/index.php/topic,1050.0.html
>
> [1,3,-5] [4,-2,1] ' n:* ' n:+ a:dot . cr
>
> outputs 3
>
> The a:dot word is a generalized dot-product of two similarly-sized
> arrays. So it can do a great deal more than a simple math dot-product.
OCaml:
let dot_prod v w mul add =
let result = ref (mul v.(0) w.(0)) in
for i = 1 to (Array.length v) - 1 do
result := add !result (mul v.(i) w.(i))
done ;
!result ;;
dot_prod [|1; 3;-5|] [|4;-2;-1|] ( * ) (+) ;;
===>
3
dot_prod [|1.; 3.; -5.|] [|4.; -2.; -1.|] ( *. ) (+.) ;;
===>
3.
dot_prod
[|"foo"; "cross"; "helter"|]
[|"bar"; "criss"; "skelter"|]
(fun a b -> List.sort compare [a;b] |> String.concat "-")
(Printf.sprintf "%s; %s") ;;
===>
"bar-foo; criss-cross; helter-skelter"
--
Goyim were born only to serve us.... They will work, they will plow, they will
reap. We will sit like an effendi and eat. --- Rabbi Ovadia Yosef
web.archive.org/web/20101020044210/http://www.jpost.com/JewishWorld/JewishNews/Article.aspx?id=191782
archive.org/download/DavidDuke_videos/TopRabbiExposesJewishRacism-cybsdwjezqi.ogv
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.forth
csiph-web