{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import Numeric.LinearAlgebra" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import IHaskell.Display" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ ":ext FlexibleInstances\n", "\n", "dec = 3\n", "\n", "instance IHaskellDisplay (Matrix C) where\n", " display m = return $ Display [html (\"
$$\"++(latexFormat \"bmatrix\" . dispcf dec) m++\"$$
\")]\n", "\n", "instance IHaskellDisplay (Matrix R) where\n", " display m = return $ Display [html (\"$$\"++ (latexFormat \"bmatrix\" . dispf dec) m++\"$$
\")]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import Graphics.SVG\n", "data RawSVG = RawSVG String\n", "instance IHaskellDisplay RawSVG where\n", " display (RawSVG s) = return $ Display [html $ \"$$\\begin{bmatrix}\n", "1.000 & 0.900 & 0.810\n", "\\\\\n", "1.000 & 2.100 & 4.410\n", "\\\\\n", "1.000 & 3.100 & 9.610\n", "\\\\\n", "1.000 & 4.000 & 16.000\n", "\\\\\n", "1.000 & 4.900 & 24.010\n", "\\\\\n", "1.000 & 6.100 & 37.210\n", "\\\\\n", "1.000 & 7.000 & 49.000\n", "\\\\\n", "1.000 & 7.900 & 62.410\n", "\\\\\n", "1.000 & 9.100 & 82.810\n", "\\\\\n", "1.000 & 10.200 & 104.040\n", "\\end{bmatrix}$$
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "expand 2 x" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": true }, "outputs": [], "source": [ "pol = polynomialModel x y\n", "view = [x, y, pol 1 x, pol 2 x, pol 3 x]" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ " x y p 1 p 2 p 3" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ " 0.90 1.10 -3.41 7.70 -6.99\n", " 2.10 3.90 6.83 9.80 15.97\n", " 3.10 9.20 15.36 13.39 25.09\n", " 4.00 51.80 23.04 18.05 28.22\n", " 4.90 25.30 30.72 24.05 28.86\n", " 6.10 35.70 40.96 34.16 29.68\n", " 7.00 49.40 48.64 43.31 33.17\n", " 7.90 3.60 56.32 53.82 41.60\n", " 9.10 81.50 66.57 69.92 64.39\n", "10.20 99.50 75.95 86.80 101.01" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import Text.Printf\n", "\n", "putStrLn \" x y p 1 p 2 p 3\"\n", "putStrLn $ format \" \" (printf \"%.2f\") $ fromColumns view" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [], "source": [ "t = linspace 100 (minElement x, maxElement x)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "