Question: BLAS ( Basic Linear Algebra Subprograms ) is a library that serves as a fundamental building block for many numerical algorithms. For example, NVIDIA s
BLAS Basic Linear Algebra Subprograms is a library that serves as a fundamental building block for many numerical algorithms. For example, NVIDIAs cuBLAS library implements highly optimized parallel versions of BLAS functions for GPU computations. Almost all neural network type AI algorithms and computer graphics algorithms that run on NVIDIA GPUs rely on cuBLAS. Likewise, Intel also provides its own BLAS library for computations on Intel CPUs. This question aims to implement a version of the gaxpy function in BLAS.
Gaxpy takes three inputs: an by matrix an vector and an vector It outputs the vector which is an vector equal to the sum of the matrixvector product and the vector For example,
a Write a function Qavalidatevectorx to validate that the input x is a proper vector, ie a list of numbers int float, or complex Return True if the input is proper, False otherwise.
Note: You may use isinstancex list to check whether x is a list and use isinstancezint float, complex to check whether z is a number.
The result must be returned via some return statements. Outputs generated by print statements will be ignored by the grader.
Sample input : Return values: True Sample input :
Return values: False Sample input : Return values: False
Sample input :
Return values: True Sample input : Return values: False Sample input :
Return values: False
b Write a function QbvalidatematrixA to validate that the input A is a proper matrix, ie a list of lists of numbers int float, or complex and of rectangular shape. Return True if the input is proper, False otherwise. See the Note in part a
Sample input : Return values: True
Sample input : Return values: True
Sample input : Return values: True
Sample input : Return values: False
Sample input : Return values: False
Sample input : Return values: False
Sample input : Return values: False
Sample input : Return values: True
Sample input : Return values: True
Sample input : Return values: True
Sample input : Return values: False
Sample input : Return values: False
Sample input : Return values: False
c Write a function QcvalidatesizeAxy to validate that the size of inputs are compatible for gaxpy, ie the number of columns in A equals the number of elements in x and the number of rows in A equals the number of elements in y Return True if the inputs are compatible, False otherwise.
Note: You may assume that A is a proper matrix, x and y are proper vectors, ie they pass the relevant tests in parts a and b
The result must be returned via some return statements. Outputs generated by print statements will be ignored by the grader.
Sample input : Return values: True
Sample input : Return values: True
Sample input : Return values: False
Sample input : Return values: False
d Write a function QdgaxpyAxy to compute and return the gaxpy. The output should be a list of numbers and of length equal to the length of y The output should be a newly created list.
Note: You may assume that the inputs are proper and compatible, ie they pass the relevant tests in parts ac
The result must be returned via some return statements. Outputs generated by print statements will be ignored by the grader.
Sample input : Return values:
Sample input : Return values:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
