PDA

View Full Version : Guide: Use the internals of OcBible!



MrSeanKon
08-07-2006, 12:30 AM
Here at Aoaforums (http://www.aoaforums.com/forum/programming-and-assembly-language/37600-guide-use-the-internals-of-ocbible.html#post404865) I created a thread.
I do not want to repeat the same posts.
You can get the most from OcBible.
Post here questions etc... :)
Always there at Aoaforums you can download the dlls etc...

AMD critical temperature
This code allows you to run a form like AMD critical temperature estimator.



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace AMD_critical_temperature
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private Functions OcBible; // Add reference for Functions.dll

public Form1()
{
InitializeComponent();
OcBible=new Functions();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{
double critical_temp=OcBible.AMD_critical_temperature(220 0,2180,2150,35,42,48);
MessageBox.Show(critical_temp.ToString(System.Glob alization.NumberFormatInfo.InvariantInfo) + " Celsius.",
"AMD critical temp is",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.Close();
}
}
}

MrSeanKon
08-27-2006, 11:38 PM
Gauss-Jordan
This routine uses Gauss-Jordan elimination (full pivoting).
Here is a C# sample code:



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Gaussian_elimination
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private Solve Linear_system; // Add reference for Solve.dll

public Form1()
{
InitializeComponent();
Linear_system=new Solve(); // Class initialization
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(248, 190);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion


[STAThread]
static void Main()
{
Application.Run(new Form1());
Application.EnableVisualStyles();
}

private void Form1_Load(object sender, System.EventArgs e)
{
double[] solutions=new double[4];
double[,] a=new double[4,5]; // Let's make a 3x3 linear system

a[1,1]=10; a[1,2]=22.5; a[1,3]=71.25; a[1,4]=-46.57;
a[2,1]=22.5; a[2,2]=71.25; a[2,3]=253.125; a[2,4]=-141.075;
a[3,1]=71.25; a[3,2]=253.125; a[3,3]=958.3125; a[3,4]=-487.4925;
solutions=Linear_system.Gauss_Jordan(a,3,4,5);
if (Linear_system.Gauss_Jordan_solutions() != 0)
{
for (int i=1; i<=3; i++)
solutions[i]=Math.Round(solutions[i],5);
MessageBox.Show("x1 = " + solutions[1].ToString() + "\nx2 = " + solutions[2].ToString()
+ "\nx3 = " + solutions[3].ToString(),"Solutions are");
}
else
MessageBox.Show("No solution can be found!","Ill conditioned problem!",
MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
}
}
}

MrSeanKon
10-08-2006, 11:05 PM
SOR w=1.25
This is an iterative method.



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace SOR_positive
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private Solve Linear_system; // Add reference for Solve.dll

public Form1()
{
InitializeComponent();
Linear_system=new Solve(); // Class initialization
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(248, 190);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion


[STAThread]
static void Main()
{
Application.Run(new Form1());
Application.EnableVisualStyles();
}

private void Form1_Load(object sender, System.EventArgs e)
{
double[] solutions=new double[4];
double[,] a=new double[4,5]; // Let's make a 3x3 linear system

a[1,1]=10; a[1,2]=22.5; a[1,3]=71.25; a[1,4]=-46.57;
a[2,1]=22.5; a[2,2]=71.25; a[2,3]=253.125; a[2,4]=-141.075;
a[3,1]=71.25; a[3,2]=253.125; a[3,3]=958.3125; a[3,4]=-487.4925;

solutions=Linear_system.SOR(a,3,4,300,5,1.25);
for (int i=1; i<=3; i++)
solutions[i]=Math.Round(solutions[i],5);
if (Linear_system.SOR_solutions() != 0)
MessageBox.Show("x1 = " + solutions[1].ToString() + "\nx2 = " + solutions[2].ToString()
+ "\nx3 = " + solutions[3].ToString(),"Solutions are");
else // If method diverges we should know what is going on
MessageBox.Show("x1 = " + solutions[1].ToString() + "\nx2 = " + solutions[2].ToString()
+ "\nx3 = " + solutions[3].ToString(),"Return values are");
this.Close();
}
}
}