using
System;
public
class
OrthogonalVector
{
public
static
void
Main()
{
int
[][] v1 = {
new
[] { 1, -2, 4 } };
int
[][] v2 = {
new
[] { 2, 5, 2 } };
int
[][] transposeOfV1 = Transpose(v1);
int
result = Dot(v2, transposeOfV1);
Console.WriteLine(
"Result = "
+ result);
}
public
static
int
[][] Transpose(
int
[][] matrix)
{
int
[][] transpose =
new
int
[(matrix[0].Length)][];
for
(
int
i = 0; i < matrix[0].Length; i++)
{
transpose[i] =
new
int
[(matrix.Length)];
for
(
int
j = 0; j < matrix.Length; j++)
{
transpose[i][j] = matrix[j][i];
}
}
return
transpose;
}
static
int
Dot(
int
[][] vect_A,
int
[][] vect_B)
{
int
product = 0;
int
n = vect_A[0].Length;
for
(
int
i = 0; i < n; i++)
{
product = product + vect_A[0][i] * vect_B[i][0];
}
return
product;
}
}