0% found this document useful (0 votes)
11 views9 pages

Linear Alg Project

Uploaded by

xi.am3cs09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views9 pages

Linear Alg Project

Uploaded by

xi.am3cs09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 9

LINEAR ALGEBRA PROJECT

GROUP MEMEBERS:
1)HASHIR (15306)

2)ALI MASEEL (15308)

3)SARAH (15312)

4)AZLAN SHAH (15435)

QUESTION 01: ORTHOGONAL,ORTHONORMAL IF NOT THEN


NORMALIZATION?
using System;

class Program

static bool IsOrthogonal(double[][] v)

double d = v[0][0] * v[1][0] + v[0][1] * v[1][1] + v[0][2] * v[1][2];

return Math.Abs(d) < double.Epsilon; // Using Epsilon for floating point comparison

static bool IsOrthonormal(double[][] v)

double m = Math.Sqrt(v[0][0] * v[0][0] + v[0][1] * v[0][1] + v[0][2] * v[0][2]);

return IsOrthogonal(v) && Math.Abs(m - 1.0) < double.Epsilon; // Using Epsilon for floating point
comparison

static void Main(string[] args)


{

double[][] v = new double[2][]

new double[] {1, 0, 0}, // Example vector, change as needed

new double[] {0, 1, 0}

};

if (IsOrthogonal(v))

Console.WriteLine("The vector is orthogonal.");

if (IsOrthonormal(v))

Console.WriteLine("The vector is also orthonormal.");

else

Console.WriteLine("The vector is orthogonal but not orthonormal.");

else

Console.WriteLine("The vector is not orthogonal.");

}
QUESTION 02: SCALAR TRIPLE PRODUCT
using System;

class ScalarTripleProductCalculator

{
private double[] A;

private double[] B;

private double[] C;

public ScalarTripleProductCalculator(double[] vA, double[] vB, double[] vC)

A = vA;

B = vB;

C = vC;

public double CalculateScalarTripleProduct()

double[] BcrossC = CrossProduct(B, C);

double dotProduct = DotProduct(A, BcrossC);

return dotProduct;

private double DotProduct(double[] v1, double[] v2)

double r = 0;

for (int i = 0; i < v1.Length; i++)

r += v1[i] * v2[i];

return r;

private double[] CrossProduct(double[] v1, double[] v2)


{

double[] r = new double[3];

r[0] = v1[1] * v2[2] - v1[2] * v2[1];

r[1] = v1[2] * v2[0] - v1[0] * v2[2];

r[2] = v1[0] * v2[1] - v1[1] * v2[0];

return r;

class Program

static void Main()

// Define vectors A, B, and C

double[] A = { 1,-2,3 };

double[] B = { 2,1,-2 };

double[] C = { 3,2,1 };

// Create a new instance of ScalarTripleProductCalculator

ScalarTripleProductCalculator c = new ScalarTripleProductCalculator(A, B, C);

// Calculate the scalar triple product

double s = c.CalculateScalarTripleProduct();

// Output the result

Console.WriteLine("Scalar Triple Product: " + s);

}
QUESTION 03: DOT AND CROSS PRODUCT OPERATION
class VectorOperations

public double[] CrossProduct(double[] v1, double[] v2)

double[] r = new double[3];

r[0] = v1[1] * v2[2] - v1[2] * v2[1];

r[1] = v1[2] * v2[0] - v1[0] * v2[2];

r[2] = v1[0] * v2[1] - v1[1] * v2[0];

return r;

public double DotProduct(double[] v1, double[] v2)

double r = 0;

for (int i = 0; i < v1.Length; i++)

r += v1[i] * v2[i];

return r;

class Program

static void Main()

// Define vectors A and B


double[] A = { 3,-3,1 };

double[] B = { 4,9,2};

// Create an instance of VectorOperations

VectorOperations v = new VectorOperations();

// Calculate and output the cross product of vectors A and B

double[] c = v.CrossProduct(A, B);

Console.WriteLine("Cross Product: [{0}, {1}, {2}]", c[0], c[1], c[2]);

// Calculate and output the dot product of vectors A and B

double d = v.DotProduct(A, B);

Console.WriteLine("Dot Product: " + d);

You might also like