I have the following algorithm I want to implement in chisel:
- Two matrices, dataX= an array of array doubles, and dataY =an array of string representing the label of the data in dataX.
- Calculate the euclidean distance of two data vectors v1, v2 and return the corresponding result as a FixedPoint.
def euclideanDist(v1: Array[Double],v2: Array[Double]): FixedPoint
- calculate the distance from a vector x in dataX to each vector of dataX and return a vector of distances.
def myDistances(x: Array[Double]): Array[FixedPoint].
For each vector x in dataX, we do:
distances= myDistances(x)
Sort the vector “distances” such that at the end we could have the vector sorted and the indices of the corresponding initial point stored in another vector “vecIndices”
Sorting with index will help me track the labels in dataY.
So I woulld like to sort the vectors along with the indices like what we do in scala as follows distances.zipWithIndex.sortBy(_._1).
can I get help with this please?
For example if I have distances=Array(7.0,99.0,3.50,2.9)
I would like to sort as Array((2.9,3), (3.5,2), (7.0,0), (99.0,1))
in chisel.
Thanks!