MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / axpy

Function axpy

linear_algebra/src/lib.py:218–228  ·  view source on GitHub ↗

input: a 'scalar' and two vectors 'x' and 'y' output: a vector computes the axpy operation

(scalar: float, x: Vector, y: Vector)

Source from the content-addressed store, hash-verified

216
217
218def axpy(scalar: float, x: Vector, y: Vector) -> Vector:
219 """
220 input: a 'scalar' and two vectors 'x' and 'y'
221 output: a vector
222 computes the axpy operation
223 """
224 # precondition
225 assert isinstance(x, Vector)
226 assert isinstance(y, Vector)
227 assert isinstance(scalar, (int, float))
228 return x * scalar + y
229
230
231def random_vector(n: int, a: int, b: int) -> Vector:

Callers 1

test_axpyMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_axpyMethod · 0.68