save Tmat in binary format

This commit is contained in:
nuknal
2024-06-15 03:04:50 +08:00
parent 4a2fc805c9
commit 0c17fee9c7
6 changed files with 245 additions and 90 deletions

26
pkg/rrc/helper.go Normal file
View 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
}