Re: Function CrossOver in VB.net
- From: "James Hahn" <jhahn@xxxxxxxxx>
- Date: Wed, 9 Sep 2009 09:34:39 +1000
The description you have provided is inconsistent with the example. The way I read it, I would have thought you were looking for:
1.6542 1.6540 +
1.6541 1.6540 + No crossover - false
1.654 1.6540 0 Crossover - true
1.6539 1.6540 - No Ccossover - false
Or, maybe you have given us the data backwards (as per your last comment). So the data really is:
1.6539 1.6540 -
1.654 1.6540 0 (assume - = 0) - false
1.6541 1.6540 + Crossover - true
1.6542 1.6540 + No Crossover
If the last one is the actual case, then the function simply needs to invert the arrays, scan the number pairs calculating the test condition, and return whenever the indicator changes from 0 to +
Private Function ArrayTest(ByVal Array1() As Double, ByVal Array2() As Double) As Boolean()
'Test each array pair and return true on change from 0 to +
Array1.Reverse()
Array2.Reverse()
'Function will fail if Array2 is shorter than Array1
Dim Result(Array1.Length - 1) As Boolean
Dim C As Integer = 0
Dim C1 As Integer
For I As Integer = 1 To Array1.Length - 1
C1 = Math.Sign(Array1(I) - Array2(I))
If C = 0 And C1 = +1 Then
Result(I) = True
Else
Result(I) = False
End If
C = C1
Next I
Result.Reverse()
Return Result
End Function
"Gum" <gum@xxxxxxxxxxxxx> wrote in message news:784A5C62-F3A9-4D0E-8589-F116383695FB@xxxxxxxxxxxxxxxx
I would like to create a function that returns true whenever Array1 crosses
over Array2. For example:
Array1 Array2
1.6542 1.6540 False
1.6541 1.6540 True
1.654 1.6540 False
1.6539 1.6540 False
Thus given any pair of numbers (Array1,Array2), whenever Array1 crosses over
Array2 (Array1>Array2) that instance is true, but it is NOT TRUE for any
other instance in which Array1>Array2 (see above table where the last record
is the first - desc order).
.
- Follow-Ups:
- Re: Function CrossOver in VB.net
- From: Gum
- Re: Function CrossOver in VB.net
- References:
- Function CrossOver in VB.net
- From: Gum
- Function CrossOver in VB.net
- Prev by Date: Re: DataGridView creates too many new rows when inserting new data
- Next by Date: Re: Function CrossOver in VB.net
- Previous by thread: Re: Function CrossOver in VB.net
- Next by thread: Re: Function CrossOver in VB.net
- Index(es):
Relevant Pages
|