C++ program creating array the uses the dot product?
normalized dot product
// Matches the Signal with the Pattern Signal using the "dot product"
// of Signal and Pattern divided by the square root of the energy of each.
// According to the Cauchy-Schwartz inequality, the result will be
// between -1 and +1; +1.0 where identical, near 0.0 where unalike and
// -1.0 when the object Signal is the negative of the pattern Signal.
//
// The Pattern must be no longer than the Signal: if it is, an error
// value of -2.0 is returned immediately. If Signal is longer than
// Pattern, then the appropriate "head" of Signal is used. Thus the
// signal vector operation is dot(Pattern[0,L-1], Signal[0,L-1]).
//
// The application, or client, can scan the Pattern along the Signal
// in a loop to create an output signal. That operation is called
// normalized cross correlation.

// Restrict the dot product to the subsignal of amplitudes from
// S[LO]..S[HI] and otherwise behave as the above function.
// Useful for client to search signal object for a matching pattern,
// such as finding the next EKG (heart wave) cycle from the current one.


I am confused what this question is asking, any help understanding it would be awesome. We have a pre set up array with quantitys inside it.


double Signal::normalizedDotProduct (const Signal& Pattern) const
{
?????
}

The dot product of two vectors is equal to the product of their magnitude multiplied by the angle between them.
a.b=|a|*|b|*cos(θ)

Also, the signal is apparently within the pattern signal, So I think you are meant to find values that match according to Cauchy-Schwarz Inequality within the array you were given.

Sorry I couldn't be of more help code-wise...

Ala00003 the right idea. A dot product is really a projection of one vector on to another but can be thought of as a sort of correlation. Look into the other formula for the dot product (they are in fact equivalent but with n years of brain rust I can't run through it) which for vectors of points [x0,x1,x2,x3] and [y0,y1,y2,y3] is x0y0+x1y1+x2y2 + ... (you're essentially multiplying XY' where Y' is Y transpose).

As far as the energy goes, I don't want to have all the fun. Take a look at this http://en.wikipedia.org/wiki/Energy_%28signal_processing%29 or a related article. Just remember these equations are for continuous time system and you need to convert them to discrete.

Anyway, try it out in the code. Post back if you have any problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.