Concept explainers
Explanation of Solution
Implementation of norm(v):
The norm() method takes the input parameter of “vec” to return the Euclidean norm of “vec” array of coordinates.
//Function definition
public static double norm(double[ ] vec)
{
/*Call the norm() by passing the “vec” and “2” and return the result of computed value. */
return norm(vec,2);
}
Explanation:
In norm() method,
- It takes the input parameter of “vec”.
- Call the norm() method by passing the “vec” and “2” and return the result of computed value of p-norm value of “vec” array of coordinates.
Implementation of norm(v, p):
The norm() method takes the input parameter of “vec” and “pow” to return the p-norm value of “vec” array of coordinates.
//Function definition
public static double norm(double[ ] vec, int pow)
{
//Declare the variables
int sum = 0;
double exp = 1.0/pow;
//Loop executes until from “i” to "vec"
for (double i : vec)
//Add the "sum" and the power of number
sum += Math.pow(i,pow);
//Return the return
return Math.pow(sum, exp);
}
Explanation:
In norm() method,
- It takes the input parameter of “vec” and “pow”.
- Loop executes until the “vec” to add the sum and power of input.
- Return the computed p-norm value of “vec” array of coordinates.
Complete Program:
/**********************************************************
* Program demonstrates how to determine the Euclidean norm*
* for two-dimensional
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
Data Structures and Algorithms in Java
- use my ID : 201909010 SOLVE ALL BY matlab Consider the graphs of the functions f(x) = m - 1x and g(x) = 2x² — n where m and n are the maximum and mean values of the digits in your student-ID number. a) Create a vector v whose elements are the digits of your student-ID number. b) Create a variable m and assign the maximum digit in v to it. Create a variable n and assign the mean value of the digits in v to it. d) Define the function f(x) and g(x) above as anonymous functions. Plot the graphs of f(x) and g(x) on the same figure using the MATLAB function ezplot. f) Find the exact values of the x-coordinates of the intersection points between the two graphs using the MATLAB function solve. g) Find the area bounded by the two graphs.arrow_forwardPython broadcasting. Rewrite the following code without for-loops using vectorization and python broadcasting. (a) Given a data matrix X and vector beta compute a vector yhat: n = X. shape [0] yhat = np.zeros(n) for i in range(n): yhat [i] = beta [0]*X[i, 0] + beta[1]*X[i,1] + beta[2]*X[i, 1]*X[i,2] yhat beta[0]*X[: ,0] + beta[1]*X[:,1] + beta[2]*X[:,1]*X[:,2]arrow_forwardThis problem is on Computer Graphics and is based on the topic 'Perspective Projection'. Please provide a step-by-step solution to the problem and explain the steps. The solution must include the General purpose perspective projection matrix. Question: Let a 3D point (423, -423, 423) be projected on a projection plane. Given that the center of the projection plane is (0.0, 0.0, -423.0) and the coordinate of the COP is (4, 2, 3). Determine the coordinate of that 3D point on the projection plane using a general purpose perspective projection matrix.arrow_forward
- Suppose we have a two-dimensional vector [ U₁ U₂]. Select all the translations that would occur on the vector from the operation [ u₁, U2 ]-[-7, -5] 2 O Shift up Shift down Shift right Shift left O No horizontal shift No vertical shiftarrow_forwardComputer Science Compute the DFT of the vector x = [0, 1, 2, 3, 4, 5] by running FFT(x) using any software tool such as matlab.arrow_forward| For any given vector x find the correct way to define the following function in MATLAB Vsin x f(x) = e* cos x 2 + cos x f = (x) exp(x) * cos(x) – sqrt(sin(x))/(2+ cos(x)) f = (x) exp(x).* cos(x) – sqrt(sin(x))/(2 + cos(x)) f = (x) e*.* cos(x) – sqrt(sin(x)). /(2 + cos(x)) f = (x) exp(x).* cos(x) – sqrt(sin(x)). /(2 + cos(x)) f : = inline (' (exp(x).* cos(x) – sqrt(sin(x)))/(2 + cos(x))', 'x')arrow_forward
- The compass gradient operators of size 3x3 are designed to measure gradients of edges oriented in eight directions: E, NE, N, NW, W, SW, S, and SE. i) Give the form of these eight operators using coefficients valued 0, 1 or – 1. ii) Specify the gradient vector direction of each mask, keeping in mind that the gradient direction is orthogonal to the edge direction.arrow_forwardThe interval between the points in the vector rt=[1:0.4:5] isarrow_forwardUse the function to find the image of v and the preimage of w. T(V1, V2, V3) = (4V2 - V1, 4V1 + 5v2), v = (3, -4, -2), w = (3, 9) (a) the image of v (b) the preimage of w (If the vector has an infinite number of solutions, give your answer in terms of the parameter t.)arrow_forward
- jupyter nootebook python with julia 1: Modify your models and coding of Chebyshev center and building a house to get the right anwsers. # Given matrix A and vector b A = [2 -1 2; -1 2 4; 1 2 -2; -1 0 0; 0 -1 0; 0 0 -1]b = [2; 16; 8; 0; 0; 0]arrow_forwardEvery vector can be normalisedarrow_forwardThe vector x ∈ R N has L different entries. For example, L = 4 for x = [3,4,4,5,3,1,5,3]T . One can express x as x = S u, where u ∈ R L satisfies (u)i < (u)j if i < j and S is a matrix that contains only zeros and ones. Write the function repeated_entries, which takes x as input and returns S and u.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrOperations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole