How to resolve the algorithm Dot product step by step in the Amazing Hopper programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Dot product step by step in the Amazing Hopper programming language
Table of Contents
Problem Statement
Create a function/use an in-built function, to compute the dot product, also known as the scalar product of two vectors. If possible, make the vectors of arbitrary length.
As an example, compute the dot product of the vectors:
If implementing the dot product of two vectors directly:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Dot product step by step in the Amazing Hopper programming language
Source code in the amazing programming language
#include
principal {
imprimir(producto punto( lst'1,3,(-5)', lst'4,(-2),(-1)' ),NL)
terminar
}
#define maincode main: {1}do
#define this {1}do
#defn out {"\n"}print
#define dotp mul;stats(0)
#defn lst(*) {"\033"} *;mklist;
#define ready {0}return
#define decim _X_DECIM=0, mov(_X_DECIM),prec(_X_DECIM),{1}do
main code{
{0}decim{
"A.B = "
this{
lst (1,3,(-5)), lst (4,(-2),(-1))
} dotp
} out
} ready
#defn dotp(_X_,_Y_) #ATOM#CMPLX;#ATOM#CMPLX; mul; stats(0)
#defn lst(*) {"\033"} *;mklist;
#defn out(*) *;{"\n"}print
#defn code(*) main:; *; {"0"};return
code( out( dotp( lst (1,3,(-5)), lst (4,(-2),(-1)) ) ) )
You may also check:How to resolve the algorithm Permutations/Derangements step by step in the Raku programming language
You may also check:How to resolve the algorithm Mayan numerals step by step in the Ruby programming language
You may also check:How to resolve the algorithm Strip whitespace from a string/Top and tail step by step in the Sidef programming language
You may also check:How to resolve the algorithm First class environments step by step in the Raku programming language
You may also check:How to resolve the algorithm De Polignac numbers step by step in the Raku programming language