Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120060019
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
Tue, Jul 1, 16:35
Size
523 B
Mime Type
text/x-c++
Expires
Thu, Jul 3, 16:35 (2 d)
Engine
blob
Format
Raw Data
Handle
27133157
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