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

chazog / 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 e5b42365 authored 6 years ago by chazog's avatar chazog
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

Upload New File

parent 3b01e3bc master
Hide whitespace changes
Inline Side-by-side
Showing with 48 additions and 0 deletions
  • Lab4/Task1.c
Lab4/Task1.c 0 → 100644
View file @ e5b42365
#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};
float sumOfSquares;
memcpy(orthogonalMatrix[0], initialVector, 6 * sizeof(float));
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