mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Added native implementation of Magento to calibrate sensors
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -7,4 +7,6 @@ build
|
||||
/bin/
|
||||
|
||||
# Syncthing ignore file
|
||||
.stignore
|
||||
.stignore
|
||||
|
||||
MagnetoLib.dll
|
||||
362
native/MagnetoLib/.gitignore
vendored
Normal file
362
native/MagnetoLib/.gitignore
vendored
Normal file
@@ -0,0 +1,362 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
2349
native/MagnetoLib/Magneto.cpp
Normal file
2349
native/MagnetoLib/Magneto.cpp
Normal file
File diff suppressed because it is too large
Load Diff
334
native/MagnetoLib/MagnetoLib.cpp
Normal file
334
native/MagnetoLib/MagnetoLib.cpp
Normal file
@@ -0,0 +1,334 @@
|
||||
// This is the main DLL file.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "magnetolib.h"
|
||||
#include "magneto.h"
|
||||
|
||||
void calculate(double data[], int nlines, double nxsrej, double hm, double B[3], double A_1[6 * 6])
|
||||
{
|
||||
int nlines2 = 0;
|
||||
char buf[120];
|
||||
double *D, *S, *C, *S11, *S12, *S12t, *S22, *S22_1, *S22a, *S22b, *SS, *E, *d, *U, *SSS;
|
||||
double *eigen_real, *eigen_imag, *v1, *v2, *v, *Q, *Q_1, *QB, J, hmb, *SSSS;
|
||||
int *p;
|
||||
int i, j, index;
|
||||
double maxval, norm, btqb, *eigen_real3, *eigen_imag3, *Dz, *vdz, *SQ, norm1, norm2, norm3;
|
||||
double x, y, z, x2, xs, xave;
|
||||
double *raw; //raw obs
|
||||
char filename[64];
|
||||
|
||||
//
|
||||
// calculate mean (norm) and standard deviation for possible outlier rejection
|
||||
//
|
||||
|
||||
xs = 0;
|
||||
xave = 0;
|
||||
for (i = 0; i < nlines; i++)
|
||||
{
|
||||
x = data[i * 3 + 0];
|
||||
y = data[i * 3 + 1];
|
||||
z = data[i * 3 + 2];
|
||||
x2 = x*x + y*y + z*z;
|
||||
xs += x2;
|
||||
xave += sqrt(x2);
|
||||
}
|
||||
xave = xave / nlines; //mean vector length
|
||||
xs = sqrt(xs / nlines - (xave*xave)); //std. dev.
|
||||
|
||||
// summarize statistics, give opportunity to reject outlier measurements
|
||||
|
||||
//printf("verage magnitude (sigma) of %d vectors (default Hm) = %6.1lf (%6.1lf)\r\n", nlines, xave, xs);
|
||||
//printf("Rejection level selected: %lf\r\n ", nxsrej);
|
||||
|
||||
// scan file again
|
||||
|
||||
nlines2 = 0; //count non-rejected
|
||||
if (nxsrej > 0) {
|
||||
//printf("\r\nRejecting measurements if abs(vector_length-average)/(std. dev.) > %5.1lf", nxsrej);
|
||||
|
||||
// outlier rejection, count them
|
||||
for (i = 0; i < nlines; i++)
|
||||
{
|
||||
x = data[i * 3 + 0];
|
||||
y = data[i * 3 + 1];
|
||||
z = data[i * 3 + 2];
|
||||
x2 = sqrt(x*x + y*y + z*z); //vector length
|
||||
x2 = fabs(x2 - xave) / xs; //standard deviations from mean
|
||||
if (x2 < nxsrej) nlines2++;
|
||||
}
|
||||
//printf("\r\n%3d measurements will be rejected", nlines - nlines2);
|
||||
}
|
||||
|
||||
// third time through!
|
||||
|
||||
if (nlines2 == 0) nlines2 = nlines; //none rejected
|
||||
j = 0; //index for good measurements
|
||||
|
||||
// allocate array space for accepted measurements
|
||||
D = (double*)malloc(10 * nlines2 * sizeof(double));
|
||||
raw = (double*)malloc(3 * nlines2 * sizeof(double));
|
||||
|
||||
for (i = 0; i < nlines; i++)
|
||||
{
|
||||
x = data[i * 3 + 0];
|
||||
y = data[i * 3 + 1];
|
||||
z = data[i * 3 + 2];
|
||||
x2 = sqrt(x*x + y*y + z*z); //vector length
|
||||
x2 = fabs(x2 - xave) / xs; //standard deviations from mean
|
||||
if ((nxsrej == 0) || (x2 < nxsrej)) {
|
||||
|
||||
raw[3 * j] = x;
|
||||
raw[3 * j + 1] = y;
|
||||
raw[3 * j + 2] = z;
|
||||
D[j] = x * x;
|
||||
D[nlines2 + j] = y * y;
|
||||
D[nlines2 * 2 + j] = z * z;
|
||||
D[nlines2 * 3 + j] = 2.0 * y * z;
|
||||
D[nlines2 * 4 + j] = 2.0 * x * z;
|
||||
D[nlines2 * 5 + j] = 2.0 * x * y;
|
||||
D[nlines2 * 6 + j] = 2.0 * x;
|
||||
D[nlines2 * 7 + j] = 2.0 * y;
|
||||
D[nlines2 * 8 + j] = 2.0 * z;
|
||||
D[nlines2 * 9 + j] = 1.0;
|
||||
j++; //index good measurements
|
||||
}
|
||||
}
|
||||
//printf("\r\n%3d measurements processed, expected %d", j, nlines2);
|
||||
nlines = nlines2; //reset number of measurements
|
||||
|
||||
if (hm == 0.0) hm = xave;
|
||||
|
||||
// allocate memory for matrix S
|
||||
S = (double*)malloc(10 * 10 * sizeof(double));
|
||||
Multiply_Self_Transpose(S, D, 10, nlines);
|
||||
|
||||
// Create pre-inverted constraint matrix C
|
||||
C = (double*)malloc(6 * 6 * sizeof(double));
|
||||
C[0] = 0.0; C[1] = 0.5; C[2] = 0.5; C[3] = 0.0; C[4] = 0.0; C[5] = 0.0;
|
||||
C[6] = 0.5; C[7] = 0.0; C[8] = 0.5; C[9] = 0.0; C[10] = 0.0; C[11] = 0.0;
|
||||
C[12] = 0.5; C[13] = 0.5; C[14] = 0.0; C[15] = 0.0; C[16] = 0.0; C[17] = 0.0;
|
||||
C[18] = 0.0; C[19] = 0.0; C[20] = 0.0; C[21] = -0.25; C[22] = 0.0; C[23] = 0.0;
|
||||
C[24] = 0.0; C[25] = 0.0; C[26] = 0.0; C[27] = 0.0; C[28] = -0.25; C[29] = 0.0;
|
||||
C[30] = 0.0; C[31] = 0.0; C[32] = 0.0; C[33] = 0.0; C[34] = 0.0; C[35] = -0.25;
|
||||
|
||||
S11 = (double*)malloc(6 * 6 * sizeof(double));
|
||||
Get_Submatrix(S11, 6, 6, S, 10, 0, 0);
|
||||
S12 = (double*)malloc(6 * 4 * sizeof(double));
|
||||
Get_Submatrix(S12, 6, 4, S, 10, 0, 6);
|
||||
S12t = (double*)malloc(4 * 6 * sizeof(double));
|
||||
Get_Submatrix(S12t, 4, 6, S, 10, 6, 0);
|
||||
S22 = (double*)malloc(4 * 4 * sizeof(double));
|
||||
Get_Submatrix(S22, 4, 4, S, 10, 6, 6);
|
||||
|
||||
S22_1 = (double*)malloc(4 * 4 * sizeof(double));
|
||||
for (i = 0; i < 16; i++)
|
||||
S22_1[i] = S22[i];
|
||||
Choleski_LU_Decomposition(S22_1, 4);
|
||||
Choleski_LU_Inverse(S22_1, 4);
|
||||
|
||||
// Calculate S22a = S22_1 * S12t 4*6 = 4x4 * 4x6 C = AB
|
||||
S22a = (double*)malloc(4 * 6 * sizeof(double));
|
||||
Multiply_Matrices(S22a, S22_1, 4, 4, S12t, 6);
|
||||
|
||||
// Then calculate S22b = S12 * S22a ( 6x6 = 6x4 * 4x6)
|
||||
S22b = (double*)malloc(6 * 6 * sizeof(double));
|
||||
Multiply_Matrices(S22b, S12, 6, 4, S22a, 6);
|
||||
|
||||
// Calculate SS = S11 - S22b
|
||||
SS = (double*)malloc(6 * 6 * sizeof(double));
|
||||
for (i = 0; i < 36; i++)
|
||||
SS[i] = S11[i] - S22b[i];
|
||||
E = (double*)malloc(6 * 6 * sizeof(double));
|
||||
Multiply_Matrices(E, C, 6, 6, SS, 6);
|
||||
|
||||
SSS = (double*)malloc(6 * 6 * sizeof(double));
|
||||
Hessenberg_Form_Elementary(E, SSS, 6);
|
||||
|
||||
eigen_real = (double*)malloc(6 * sizeof(double));
|
||||
eigen_imag = (double*)malloc(6 * sizeof(double));
|
||||
|
||||
QR_Hessenberg_Matrix(E, SSS, eigen_real, eigen_imag, 6, 100);
|
||||
|
||||
index = 0;
|
||||
maxval = eigen_real[0];
|
||||
for (i = 1; i < 6; i++)
|
||||
{
|
||||
if (eigen_real[i] > maxval)
|
||||
{
|
||||
maxval = eigen_real[i];
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
v1 = (double*)malloc(6 * sizeof(double));
|
||||
|
||||
v1[0] = SSS[index];
|
||||
v1[1] = SSS[index + 6];
|
||||
v1[2] = SSS[index + 12];
|
||||
v1[3] = SSS[index + 18];
|
||||
v1[4] = SSS[index + 24];
|
||||
v1[5] = SSS[index + 30];
|
||||
|
||||
// normalize v1
|
||||
norm = sqrt(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2] + v1[3] * v1[3] + v1[4] * v1[4] + v1[5] * v1[5]);
|
||||
v1[0] /= norm;
|
||||
v1[1] /= norm;
|
||||
v1[2] /= norm;
|
||||
v1[3] /= norm;
|
||||
v1[4] /= norm;
|
||||
v1[5] /= norm;
|
||||
|
||||
if (v1[0] < 0.0)
|
||||
{
|
||||
v1[0] = -v1[0];
|
||||
v1[1] = -v1[1];
|
||||
v1[2] = -v1[2];
|
||||
v1[3] = -v1[3];
|
||||
v1[4] = -v1[4];
|
||||
v1[5] = -v1[5];
|
||||
}
|
||||
|
||||
// Calculate v2 = S22a * v1 ( 4x1 = 4x6 * 6x1)
|
||||
v2 = (double*)malloc(4 * sizeof(double));
|
||||
Multiply_Matrices(v2, S22a, 4, 6, v1, 1);
|
||||
|
||||
v = (double*)malloc(10 * sizeof(double));
|
||||
|
||||
v[0] = v1[0];
|
||||
v[1] = v1[1];
|
||||
v[2] = v1[2];
|
||||
v[3] = v1[3];
|
||||
v[4] = v1[4];
|
||||
v[5] = v1[5];
|
||||
v[6] = -v2[0];
|
||||
v[7] = -v2[1];
|
||||
v[8] = -v2[2];
|
||||
v[9] = -v2[3];
|
||||
|
||||
Q = (double*)malloc(3 * 3 * sizeof(double));
|
||||
|
||||
Q[0] = v[0];
|
||||
Q[1] = v[5];
|
||||
Q[2] = v[4];
|
||||
Q[3] = v[5];
|
||||
Q[4] = v[1];
|
||||
Q[5] = v[3];
|
||||
Q[6] = v[4];
|
||||
Q[7] = v[3];
|
||||
Q[8] = v[2];
|
||||
|
||||
U = (double*)malloc(3 * sizeof(double));
|
||||
|
||||
U[0] = v[6];
|
||||
U[1] = v[7];
|
||||
U[2] = v[8];
|
||||
Q_1 = (double*)malloc(3 * 3 * sizeof(double));
|
||||
for (i = 0; i < 9; i++)
|
||||
Q_1[i] = Q[i];
|
||||
Choleski_LU_Decomposition(Q_1, 3);
|
||||
Choleski_LU_Inverse(Q_1, 3);
|
||||
|
||||
// Calculate B = Q-1 * U ( 3x1 = 3x3 * 3x1)
|
||||
Multiply_Matrices(B, Q_1, 3, 3, U, 1);
|
||||
B[0] = -B[0]; // x-axis combined bias
|
||||
B[1] = -B[1]; // y-axis combined bias
|
||||
B[2] = -B[2]; // z-axis combined bias
|
||||
|
||||
// for(i = 0; i < 3; i++)
|
||||
//printf("\r\nCombined bias vector B:\r\n");
|
||||
//printf("%8.2lf %8.2lf %8.2lf \r\n", B[0], B[1], B[2]);
|
||||
|
||||
// First calculate QB = Q * B ( 3x1 = 3x3 * 3x1)
|
||||
QB = (double*)malloc(3 * sizeof(double));
|
||||
Multiply_Matrices(QB, Q, 3, 3, B, 1);
|
||||
|
||||
// Then calculate btqb = BT * QB ( 1x1 = 1x3 * 3x1)
|
||||
Multiply_Matrices(&btqb, B, 1, 3, QB, 1);
|
||||
|
||||
// Calculate hmb = sqrt(btqb - J).
|
||||
J = v[9];
|
||||
hmb = sqrt(btqb - J);
|
||||
|
||||
// Calculate SQ, the square root of matrix Q
|
||||
SSSS = (double*)malloc(3 * 3 * sizeof(double));
|
||||
Hessenberg_Form_Elementary(Q, SSSS, 3);
|
||||
|
||||
eigen_real3 = (double*)malloc(3 * sizeof(double));
|
||||
eigen_imag3 = (double*)malloc(3 * sizeof(double));
|
||||
QR_Hessenberg_Matrix(Q, SSSS, eigen_real3, eigen_imag3, 3, 100);
|
||||
|
||||
// normalize eigenvectors
|
||||
norm1 = sqrt(SSSS[0] * SSSS[0] + SSSS[3] * SSSS[3] + SSSS[6] * SSSS[6]);
|
||||
SSSS[0] /= norm1;
|
||||
SSSS[3] /= norm1;
|
||||
SSSS[6] /= norm1;
|
||||
norm2 = sqrt(SSSS[1] * SSSS[1] + SSSS[4] * SSSS[4] + SSSS[7] * SSSS[7]);
|
||||
SSSS[1] /= norm2;
|
||||
SSSS[4] /= norm2;
|
||||
SSSS[7] /= norm2;
|
||||
norm3 = sqrt(SSSS[2] * SSSS[2] + SSSS[5] * SSSS[5] + SSSS[8] * SSSS[8]);
|
||||
SSSS[2] /= norm3;
|
||||
SSSS[5] /= norm3;
|
||||
SSSS[8] /= norm3;
|
||||
|
||||
Dz = (double*)malloc(3 * 3 * sizeof(double));
|
||||
for (i = 0; i < 9; i++)
|
||||
Dz[i] = 0.0;
|
||||
Dz[0] = sqrt(eigen_real3[0]);
|
||||
Dz[4] = sqrt(eigen_real3[1]);
|
||||
Dz[8] = sqrt(eigen_real3[2]);
|
||||
|
||||
vdz = (double*)malloc(3 * 3 * sizeof(double));
|
||||
Multiply_Matrices(vdz, SSSS, 3, 3, Dz, 3);
|
||||
|
||||
Transpose_Square_Matrix(SSSS, 3);
|
||||
|
||||
SQ = (double*)malloc(3 * 3 * sizeof(double));
|
||||
Multiply_Matrices(SQ, vdz, 3, 3, SSSS, 3);
|
||||
|
||||
// hm = 0.569;
|
||||
for (i = 0; i < 9; i++)
|
||||
A_1[i] = SQ[i] * hm / hmb;
|
||||
|
||||
/*
|
||||
printf("\r\nCorrection matrix Ainv, using Hm=%lf:\r\n", hm);
|
||||
for (i = 0; i < 3; i++)
|
||||
printf("%9.5lf %9.5lf %9.5lf\r\n", A_1[i * 3], A_1[i * 3 + 1], A_1[i * 3 + 2]);
|
||||
printf("\r\nWhere Hcalc = Ainv*(H-B)\r\n");
|
||||
|
||||
printf("\r\nCode initialization statements...\r\n");
|
||||
printf("\r\n float B[3]\r\n {%8.2lf,%8.2lf,%8.2lf};\r\n", B[0], B[1], B[2]);
|
||||
printf("\r\n float Ainv[3][3]\r\n {{%9.5lf,%9.5lf,%9.5lf},\r\n", A_1[0], A_1[1], A_1[2]);
|
||||
printf(" {%9.5lf,%9.5lf,%9.5lf},\r\n", A_1[3], A_1[4], A_1[5]);
|
||||
printf(" {%9.5lf,%9.5lf,%9.5lf}};\r\n", A_1[6], A_1[7], A_1[8]);
|
||||
//*/
|
||||
|
||||
free(D);
|
||||
free(S);
|
||||
free(C);
|
||||
free(S11);
|
||||
free(S12);
|
||||
free(S12t);
|
||||
free(S22);
|
||||
free(S22_1);
|
||||
free(S22a);
|
||||
free(S22b);
|
||||
free(SS);
|
||||
free(E);
|
||||
free(U);
|
||||
free(SSS);
|
||||
free(eigen_real);
|
||||
free(eigen_imag);
|
||||
free(v1);
|
||||
free(v2);
|
||||
free(v);
|
||||
free(Q);
|
||||
free(Q_1);
|
||||
free(QB);
|
||||
free(SSSS);
|
||||
free(eigen_real3);
|
||||
free(eigen_imag3);
|
||||
free(Dz);
|
||||
free(vdz);
|
||||
free(SQ);
|
||||
}
|
||||
31
native/MagnetoLib/MagnetoLib.sln
Normal file
31
native/MagnetoLib/MagnetoLib.sln
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.15
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MagnetoLib", "MagnetoLib.vcxproj", "{E9872CD1-7CFB-4344-B141-8583E3A52C34}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E9872CD1-7CFB-4344-B141-8583E3A52C34}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E9872CD1-7CFB-4344-B141-8583E3A52C34}.Debug|x64.Build.0 = Debug|x64
|
||||
{E9872CD1-7CFB-4344-B141-8583E3A52C34}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E9872CD1-7CFB-4344-B141-8583E3A52C34}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E9872CD1-7CFB-4344-B141-8583E3A52C34}.Release|x64.ActiveCfg = Release|x64
|
||||
{E9872CD1-7CFB-4344-B141-8583E3A52C34}.Release|x64.Build.0 = Release|x64
|
||||
{E9872CD1-7CFB-4344-B141-8583E3A52C34}.Release|x86.ActiveCfg = Release|Win32
|
||||
{E9872CD1-7CFB-4344-B141-8583E3A52C34}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3F5C7B4A-6B24-4FE5-A65E-8CCED5E98FD6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
164
native/MagnetoLib/MagnetoLib.vcxproj
Normal file
164
native/MagnetoLib/MagnetoLib.vcxproj
Normal file
@@ -0,0 +1,164 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{E9872CD1-7CFB-4344-B141-8583E3A52C34}</ProjectGuid>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
<RootNamespace>MagnetoLib</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies />
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies />
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies />
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies />
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Magneto.h" />
|
||||
<ClInclude Include="MagnetoLib.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="Stdafx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AssemblyInfo.cpp" />
|
||||
<ClCompile Include="Magneto.cpp" />
|
||||
<ClCompile Include="MagnetoLib.cpp" />
|
||||
<ClCompile Include="Stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="app.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="app.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
58
native/MagnetoLib/MagnetoLib.vcxproj.filters
Normal file
58
native/MagnetoLib/MagnetoLib.vcxproj.filters
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="MagnetoLib.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Stdafx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Magneto.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="MagnetoLib.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AssemblyInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Stdafx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Magneto.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="app.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="app.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
BIN
native/MagnetoLib/app.rc
Normal file
BIN
native/MagnetoLib/app.rc
Normal file
Binary file not shown.
38
native/MagnetoLib/assemblyinfo.cpp
Normal file
38
native/MagnetoLib/assemblyinfo.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Reflection;
|
||||
using namespace System::Runtime::CompilerServices;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
using namespace System::Security::Permissions;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly:AssemblyTitleAttribute(L"MagnetoLib")];
|
||||
[assembly:AssemblyDescriptionAttribute(L"")];
|
||||
[assembly:AssemblyConfigurationAttribute(L"")];
|
||||
[assembly:AssemblyCompanyAttribute(L"")];
|
||||
[assembly:AssemblyProductAttribute(L"MagnetoLib")];
|
||||
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2021")];
|
||||
[assembly:AssemblyTrademarkAttribute(L"")];
|
||||
[assembly:AssemblyCultureAttribute(L"")];
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the value or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly:AssemblyVersionAttribute("1.0.*")];
|
||||
|
||||
[assembly:ComVisible(false)];
|
||||
|
||||
[assembly:CLSCompliantAttribute(true)];
|
||||
32
native/MagnetoLib/magneto.h
Normal file
32
native/MagnetoLib/magneto.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
// Forward declarations of mymathlib.com routines
|
||||
void Multiply_Self_Transpose(double*, double*, int, int);
|
||||
void Get_Submatrix(double*, int, int, double*, int, int, int);
|
||||
int Choleski_LU_Decomposition(double*, int);
|
||||
int Choleski_LU_Inverse(double*, int);
|
||||
void Multiply_Matrices(double*, double*, int, int, double*, int);
|
||||
void Identity_Matrix(double*, int);
|
||||
|
||||
int Hessenberg_Form_Elementary(double*, double*, int);
|
||||
static void Hessenberg_Elementary_Transform(double*, double*, int[], int);
|
||||
|
||||
void Copy_Vector(double*, double*, int);
|
||||
|
||||
int QR_Hessenberg_Matrix(double*, double*, double[], double[], int, int);
|
||||
static void One_Real_Eigenvalue(double[], double[], double[], int, double);
|
||||
static void Two_Eigenvalues(double*, double*, double[], double[], int, int, double);
|
||||
static void Update_Row(double*, double, double, int, int);
|
||||
static void Update_Column(double*, double, double, int, int);
|
||||
static void Update_Transformation(double*, double, double, int, int);
|
||||
static void Double_QR_Iteration(double*, double*, int, int, int, double*, int);
|
||||
static void Product_and_Sum_of_Shifts(double*, int, int, double*, double*, double*, int);
|
||||
static int Two_Consecutive_Small_Subdiagonal(double*, int, int, int, double, double);
|
||||
static void Double_QR_Step(double*, int, int, int, double, double, double*, int);
|
||||
static void BackSubstitution(double*, double[], double[], int);
|
||||
static void BackSubstitute_Real_Vector(double*, double[], double[], int, double, int);
|
||||
static void BackSubstitute_Complex_Vector(double*, double[], double[], int, double, int);
|
||||
static void Calculate_Eigenvectors(double*, double*, double[], double[], int);
|
||||
static void Complex_Division(double, double, double, double, double*, double*);
|
||||
|
||||
void Transpose_Square_Matrix(double*, int);
|
||||
31
native/MagnetoLib/magnetolib.h
Normal file
31
native/MagnetoLib/magnetolib.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// MagnetoLib.h
|
||||
#pragma once
|
||||
|
||||
// Define EXPORTED for any platform
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#ifdef WIN_EXPORT
|
||||
// Exporting...
|
||||
#ifdef __GNUC__
|
||||
#define EXPORTED __attribute__ ((dllexport))
|
||||
#else
|
||||
#define EXPORTED __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
|
||||
#endif
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define EXPORTED __attribute__ ((dllimport))
|
||||
#else
|
||||
#define EXPORTED __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
|
||||
#endif
|
||||
#endif
|
||||
#define NOT_EXPORTED
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#define EXPORTED __attribute__ ((visibility ("default")))
|
||||
#define NOT_EXPORTED __attribute__ ((visibility ("hidden")))
|
||||
#else
|
||||
#define EXPORTED
|
||||
#define NOT_EXPORTED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern "C" EXPORTED void calculate(double data[], int nlines, double nxsrej, double hm, double B[3], double A_1[6 * 6]);
|
||||
3
native/MagnetoLib/resource.h
Normal file
3
native/MagnetoLib/resource.h
Normal file
@@ -0,0 +1,3 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by app.rc
|
||||
5
native/MagnetoLib/stdafx.cpp
Normal file
5
native/MagnetoLib/stdafx.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// MagnetoLib.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
13
native/MagnetoLib/stdafx.h
Normal file
13
native/MagnetoLib/stdafx.h
Normal file
@@ -0,0 +1,13 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently,
|
||||
// but are changed infrequently
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include <math.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
|
||||
Reference in New Issue
Block a user