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
- Questionarrow_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_forwardSolve the following problem in Pythonarrow_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_forward# Computer Vision # Geometry Quizarrow_forwardMatlab onesarrow_forward
- Modify the Chebyshev center coding with julia in a simple style using vectors, matrices and for loops # Given matrix A and vector bA = [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] A small sample:Let t_(l),t_(o),t_(m),t_(n),t_(t),t_(s) be starttimes of the associated tasks.Now use the graph to write thedependency constraints:Tasks o,m, and n can't start until task I is finished, and task Itakes 3 days to finish. So the constraints are:t_(l)+3<=t_(o),t_(l)+3<=t_(m),t_(l)+3<=t_(n)Task t can't start until tasks m and n are finished. Therefore:t_(m)+1<=t_(t),t_(n)+2<=t_(t),Task s can't start until tasks o and t are finished. Therefore:t_(o)+3<=t_(s),t_(t)+3<=t_(s)arrow_forwardComputer sciencearrow_forwardThe 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_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