Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

emonyi / IAX0583

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit 7b4ae79f authored 6 years ago by emonyi's avatar emonyi
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

Upload New File

parent de265d6b master
Hide whitespace changes
Inline Side-by-side
Showing with 54 additions and 0 deletions
  • lab4/task1.c
lab4/task1.c 0 → 100644
View file @ 7b4ae79f
#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;
}
This diff is collapsed. Click to expand it.
  • Write
  • Preview
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