473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Check difference between two vectors

Hello,

Is it possible given two vectors, A and B, create a third vector, C,
using the following conditions, without a loop?

D = A - B

If D(i) * D(i-1) < 0 and D(i) 0 then C(i) = 1

If D(i) * D(i-1) < 0 and D(i) < 0 then C(i) = -1

If D(i) * D(i-1) 0 then C(i) = 0

---

If D(i) * D(i-1) = 0 then

If D(i) * D(i-2) < 0 and D(i) 0 then C(i) = 1

If D(i) * D(i-2) < 0 and D(i) < 0 then C(i) = -1

If D(i) * D(i-2) 0 then C(i) = 0

end

Basically I am creating a function that detects when a function
crosses under or over another function or a constant level ...

This was what I came up with ...
.... the second part is because sometimes the values can be equal
before the cross occurs ...

I am trying to make this with vectors.

Thank You,
Miguel
Feb 15 '08 #1
1 952
On Feb 15, 4:36 pm, shapper <mdmo...@gmail.comwrote:
Hello,

Is it possible given two vectors, A and B, create a third vector, C,
using the following conditions, without a loop?

D = A - B

If D(i) * D(i-1) < 0 and D(i) 0 then C(i) = 1

If D(i) * D(i-1) < 0 and D(i) < 0 then C(i) = -1

If D(i) * D(i-1) 0 then C(i) = 0

---

If D(i) * D(i-1) = 0 then

If D(i) * D(i-2) < 0 and D(i) 0 then C(i) = 1

If D(i) * D(i-2) < 0 and D(i) < 0 then C(i) = -1

If D(i) * D(i-2) 0 then C(i) = 0

end

Basically I am creating a function that detects when a function
crosses under or over another function or a constant level ...

This was what I came up with ...
... the second part is because sometimes the values can be equal
before the cross occurs ...

I am trying to make this with vectors.

Thank You,
Miguel
Ooops, forget it. I posted this on the wrong group.

Sorry,
Miguel
Feb 15 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rex_chaos | last post by:
Hi there, I have a question about using expression template. We know that the final calculation in expression template will end up with a series of element-by-element operations. The concept can...
2
by: Peter Steiner | last post by:
hi there! my problem: i need arrays of float-triples (math vector). i need these available in a flat float* array for batch processing (opengl). is an array of POD structs with three float...
1
by: Rob | last post by:
How would I do this? I want to be able to handle vectors of many different types of data and vectors that can contain any number of other vectors of data. Currently, I have a templated...
1
by: 55555 | last post by:
what is difference between variable type and object type??
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.