save Tmat in binary format
This commit is contained in:
26
pkg/rrc/helper.go
Normal file
26
pkg/rrc/helper.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package rrc
|
||||
|
||||
func searchVL(V []float64, Sik float64) int {
|
||||
left, right := 0, len(V)-2
|
||||
|
||||
// if Sik < V[0] || Sik > V[len(V)-1] {
|
||||
// return -1
|
||||
// }
|
||||
|
||||
for left <= right {
|
||||
mid := left + (right-left)/2
|
||||
// Check if Sik is between V[mid] and V[mid+1]
|
||||
if V[mid]-1e-6 <= Sik && Sik <= V[mid+1]+1e-6 {
|
||||
return mid
|
||||
} else if Sik < V[mid] {
|
||||
right = mid - 1
|
||||
} else if Sik == V[mid] {
|
||||
return mid
|
||||
} else {
|
||||
left = mid + 1
|
||||
}
|
||||
}
|
||||
|
||||
// Return -1 if no such position is found
|
||||
return -1
|
||||
}
|
||||
Reference in New Issue
Block a user