Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78976904
scalar_product.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Aug 24, 02:19
Size
523 B
Mime Type
text/x-c++
Expires
Mon, Aug 26, 02:19 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
20130604
Attached To
R9360 PCSC_git
scalar_product.cpp
View Options
#include "myvector_template_dim.hh"
#include <iostream>
// function to make the scalar product between to vectors
template
<
typename
T
,
int
dim
>
T
scalarProduct
(
const
MyVector
<
T
,
dim
>
&
v1
,
// vector1
const
MyVector
<
T
,
dim
>
&
v2
// vector2
)
{
T
res
;
for
(
int
d
=
0
;
d
<
dim
;
++
d
)
res
+=
v1
[
d
]
*
v2
[
d
];
return
res
;
}
int
main
()
{
// using it
MyVector
<
double
>
vector1_3d
;
MyVector
<
double
>
vector2_3d
;
double
res
=
scalarProduct
(
vector1_3d
,
vector2_3d
);
std
::
cout
<<
res
<<
std
::
endl
;
}
Event Timeline
Log In to Comment