Hi All,
I have two two-dimensional arrays and I want to assign one's second dimension's values as the other's second dimension's values in this way:
int userCounter = 0;
for (int userID : mostCommonUsers) {
reducedTrainingVectorForSimilarity[userCounter] = trainingVectorForSimilarity[userID];
userCounter++;
}
In the above code, I have an *"ArrayList<Integer> mostCommonUsers"*, and iterate through this. I'm using the values inside this array list, as a first dimension's index number of the *"trainingVectorForSimilarity"*, and assigning all the values in the second dimension to the left-hand-side array's second dimension. Both array has fixed length of second dimension. So, am I right by doing this, or I should make a for-loop to iterate over the individual values on the second dimensions of both arrays?
Another similar question: In the below code, *"trainingVectorForSimilarity"* is an *"float[][]"*, so basically I assign all the second dimensions' values into a newly created array named *"trainingUserRatings"*. Again, I assumed that if the corresponding first dimesion's second dimension values will be assign without any iteration over each values.
for (int i = 0; i < trainingVectorForSimilarity.length; i++) {
float[] trainingUserRatings = trainingVectorForSimilarity;
similarity[i] = calculateCosineSimilarity(testingVectorForSimilarity, trainingUserRatings);
}
Am I right for both cases?