Commit 7db863da by matjul

Upload New File

parent 38fd75d9
Showing with 47 additions and 0 deletions
#include <stdio.h>
#include <string.h>
int main(){
float orthogonalMatrix[6][6];
float initialVector[6] = {0.3, 0.4, -2, -4.4, 2.2, 3};
memcpy(orthogonalMatrix[0], initialVector, 6*sizeof(float));
float sumOfSquares;
for(int i = 1; i < 6; i++){
sumOfSquares = 0;
if(initialVector[i] == 0){
orthogonalMatrix[i] [i-1] = 1;
}
for(int j = i; j < 6; j++){
sumOfSquares += initialVector[j] * initialVector[j];
}
if(sumOfSquares == 0){
for(int j = i; j < 6; j++){
orthogonalMatrix[j][j] = 1;
}
}
initialVector[i-1] = -1 * sumOfSquares / initialVector[i-1];
memcpy(orthogonalMatrix[i], initialVector, 6*sizeof(float));
initialVector[i-1] = 0;
}
for(int i = 0; i < 6; i++){
for(int j = 0; j < 6; j++){
printf("%f,", orthogonalMatrix[i][j]);
}
printf("\n");
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment