Results 1 to 3 of 3

Thread: Guide: Use the internals of OcBible!

  1. #1
    Xtreme Member
    Join Date
    May 2005
    Location
    With my destiny :)
    Posts
    345

    Guide: Use the internals of OcBible!

    Here at Aoaforums 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.

    Code:
    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(2200,2180,2150,35,42,48);
    			MessageBox.Show(critical_temp.ToString(System.Globalization.NumberFormatInfo.InvariantInfo) + " Celsius.",
    				"AMD critical temp is",MessageBoxButtons.OK,MessageBoxIcon.Information);
    			this.Close();
    		}
    	}
    }
    Last edited by MrSeanKon; 11-15-2006 at 03:03 AM.

  2. #2
    Xtreme Member
    Join Date
    May 2005
    Location
    With my destiny :)
    Posts
    345
    Gauss-Jordan
    This routine uses Gauss-Jordan elimination (full pivoting).
    Here is a C# sample code:

    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();
    		}
    	}
    }
    Last edited by MrSeanKon; 10-08-2006 at 11:06 PM.

  3. #3
    Xtreme Member
    Join Date
    May 2005
    Location
    With my destiny :)
    Posts
    345
    SOR w=1.25
    This is an iterative method.

    Code:
    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();
    		}
    	}
    }
    Last edited by MrSeanKon; 11-15-2006 at 03:03 AM.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •