1,105,395 Community Members

C++ program creating a class that uses a dot product on an array?

Member Avatar
Newbie Poster
3 posts since Mar 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

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

Member Avatar
Newbie Poster
3 posts since Mar 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

The dot product of two vectors is equal to the product of their magnitude multiplied by the angle between them.

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...

Member Avatar
Quantitative Phrenologist
4,273 posts since Sep 2009
Reputation Points: 1,059 [?]
Q&As Helped to Solve: 607 [?]
Skill Endorsements: 14 [?]
Team Colleague

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.

This article has been dead for over three months: Start a new discussion instead
Start New Discussion
Tags Related to this Article