Rss Feed
Tweeter button
Facebook button
Technorati button
Reddit button
Myspace button
Linkedin button
Webonews button
Delicious button
Digg button
Flickr button
Stumbleupon button
Newsvine button
Youtube button

Notes:

  • The site will be morphing over the next little while.
  • I am having some issues with tabs/spaces in the Python code. Sometimes they are correct, sometimes they get eaten. I am trying to figure it out.

Please feel free to leave a comment on a post if it interests you or if you have questions

Jan 272010

I have been working on some numerical problems in the last few weeks.  Mostly related to curve fitting and interpolation.  I am slowly sliding back to Java bit-by-bit though I am not sure if I will give up Python as the syntax is so tight and it is actually very fast.

Anyway, I was looking around for some curve fitting and interpolation code on the Net and found Michael Flannigan’s website which has a great resource of math, stats, optimization and some other  more subtle items.  His Java code is here.

I can’t even do it justice by showing the list of packages as it is about twice as long as the screen capture shown to the right.

Jun 132009

There is a neat way that an application/applet can be written such that it can run as a GUI in a web page or as a GUI application. Create the Test.java code as:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;

public class Test extends JFrame {

    public Test() {
    }

        public static void main(String args[])
        {
                JFrame jf = new JFrame();
                jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                TestApplet app = new TestApplet();
                app.init();
                jf.getContentPane().add("Center", app);
                jf.setSize(600,600);
                jf.setVisible(true);
                jf.repaint();

        }
}

and create the TestApplet.java code as:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.GridLayout;
import java.awt.event.*;
import java.awt.Font;

public class TestApplet extends JApplet implements ActionListener, DocumentListener
{
    JPanel main_panel = null;

    public TestApplet()
    {
        createTestApplet();

    }

    public void init()
    {
    }

    private void createTestApplet()
    {
        // Create the two panels, one for input and the other for gradient
        // table output
        main_panel = new JPanel(new GridLayout(1,2));
        add( main_panel );

    }

    public void insertUpdate(DocumentEvent e )
        { changedUpdate(e); }

    public void removeUpdate(DocumentEvent e )
        { changedUpdate(e); }

    public void changedUpdate(DocumentEvent e)
    {
    }

    public void actionPerformed(ActionEvent e)
    {

    }
}

And then to compile it, just do:

1
$ javac Test.java

And now to run it

You can either run it from the command line:

1
$ java Test

or create a web page:

1
2
3
4
5
6
7
8
9
<html>
<head>
</head>
<body>

<applet code="Test" archive="Test.jar" height="600" width="600"></applet>

</body>
</html>
© 2010 Math, Computing and Research Please leave a comment or contact me craig@mri.brechmos.org if you have any questions. Suffusion WordPress theme by Sayontan Sinha