Skip to content

Instantly share code, notes, and snippets.

@heroyu
Created January 5, 2013 13:50
Show Gist options
  • Save heroyu/4461654 to your computer and use it in GitHub Desktop.
Save heroyu/4461654 to your computer and use it in GitHub Desktop.
Date Author Comment 05-01-2013 heroyu Create it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FTAPP
{
class Matrix
{
double[,] matrix;
int rows, columns;
private static Matrix calibrationMatrix;
public static Matrix CalibrationMatrix
{
get {return calibrationMatrix;}
}
/*
public void SetData(int _i, int _j, double _value)
{
this[_i, _j] = _value;
}
public double GetData(int _i, int _j)
{
return this[_i, _j];
}
*/
// This will not be called till before the application terminates
~Matrix()
{
//
}
public Matrix(int sizeA, int sizeB)
{
rows = sizeA;
columns = sizeB;
matrix = new double[sizeA, sizeB];
}
/* F/T Sensor Calibration Matrix */
public static void SetCalibrationMatrix()
{
calibrationMatrix = new Matrix(6, 6);
calibrationMatrix[0, 0] = -0.093436621130; calibrationMatrix[0, 1] = 0.115474052727; calibrationMatrix[0, 2] = 1.528186559677; calibrationMatrix[0, 3] = -19.691669464111; calibrationMatrix[0, 4] = -0.753080368042; calibrationMatrix[0, 5] = 23.117815017700;
calibrationMatrix[1, 0] = -1.120655894279; calibrationMatrix[1, 1] = 22.637573242188; calibrationMatrix[1, 2] = 0.694017291069; calibrationMatrix[1, 3] = -11.260780334473; calibrationMatrix[1, 4] = 0.574209690094; calibrationMatrix[1, 5] = -13.286062240601;
calibrationMatrix[2, 0] = 30.217823028565; calibrationMatrix[2, 1] = -0.809691011906; calibrationMatrix[2, 2] = 29.938171386719; calibrationMatrix[2, 3] = -1.349689841270; calibrationMatrix[2, 4] = 30.000436782837; calibrationMatrix[2, 5] = -1.381491661072;
calibrationMatrix[3, 0] = -0.018413484097; calibrationMatrix[3, 1] = 0.270402222872; calibrationMatrix[3, 2] = -1.012317061424; calibrationMatrix[3, 3] = -0.089849784970; calibrationMatrix[3, 4] = 1.033480882645; calibrationMatrix[3, 5] = -0.204911842942;
calibrationMatrix[4, 0] = 1.207050561905; calibrationMatrix[4, 1] = -0.031824681908; calibrationMatrix[4, 2] = -0.607400000095; calibrationMatrix[4, 3] = 0.261291444302; calibrationMatrix[4, 4] = -0.582980811596; calibrationMatrix[4, 5] = -0.247878879309;
calibrationMatrix[5, 0] = 0.037201803178; calibrationMatrix[5, 1] = -0.673901915550; calibrationMatrix[5, 2] = 0.041472688317; calibrationMatrix[5, 3] = -0.670206844807; calibrationMatrix[5, 4] = 0.034041989595; calibrationMatrix[5, 5] = -0.790557265282;
}
// Indexer for setting/getting internal array elements
public double this[int i, int j]
{
set { matrix[i, j] = value; }
get { return matrix[i, j]; }
}
// Return number of rows in the matrix
public int Rows
{
get { return rows; }
}
// Return number of columns in the matrix
public int Columns
{
get { return columns; }
}
// Matrix multiplication routine
public static void Matmul(Matrix A, Matrix B, Matrix C)
{
int i, j, k;
for (i = 0; i < A.Rows; i++)
{
for (j = 0; j < B.Columns; j++)
{
C[i, j] = 0;
for (k = 0; k < A.Rows; k++)
{
C[i,j] += A[i, k] * B[k, j];
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment