Scalar product
The scalar product of two vectors
and
is
.
Write a function that returns the scalar product of @u@ and @v@.
Interface
| C++ |
double scalar_product(const vector<double>& u, const vector<double>& v);
|
| C |
double scalar_product(int n, double u[n], double v[n]);
|
| Java |
public static double scalarProduct(double[] u, double[] v);
|
| Python |
scalar_product(u, v) # returns float
|
| MyPy |
scalar_product(u: list[float], v: list[float]) -> float
|
Precondition
The vectors @u@ and @v@ have the same size.
Observation
You only need to submit the required procedure; your main program
will be ignored.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T11:38:17.676Z
© Jutge.org, 2006–2026.
https://jutge.org