Please feel free to experiment here, after the four dashes below... and please do NOT create new pages without any meaningful content just to try it out!

Tip: Shift-click "HelpOnEditing" to open a second window with the help pages.


data S = Do | Re | Mi

data Song = Do | Re | Mi

\}\}\}

Hint: Add your favorite pages to your navibar. See your Quicklinks list in your user preferences.

onsider a vector represented as a list of doubles. Suppose we want to normalize a vector. The standard method is to compute the length in one pass, and scale the vector in another pass

type Vector = [Double]

normSquared :: Vector -> Double
normSquared = sum . map (^2)

norm :: Vector -> Double
norm = sqrt . normSquared

scale :: Double -> Vector -> Vector
scale a = map (a*)

normalize :: Vector -> Vector
normalize v = scale (recip (norm v)) v

It is possible to do scale and normSquared at the same time. Internally the data must still be processed twice but this can be hidden.

Consider a vector represented as a list of doubles. Suppose we want to normalize a vector. The standard method is to compute the length in one pass, and scale the vector in another pass:

type Vector = [Double]

normSquared :: Vector -> Double
normSquared = sum . map (^2)

norm :: Vector -> Double
norm = sqrt . normSquared

scale :: Double -> Vector -> Vector
scale a = map (a*)

normalize :: Vector -> Vector
normalize v = scale (recip (norm v)) v

It is possible to do scale and normSquared at the same time. Internally the data must still be processed twice but this can be hidden.

   1 -- fst of the result is the scaled value of the vector
   2 -- snd of the result is the squared norm of the vector before scaling
   3 scaleAndNormSquared :: Double -> Vector -> (Vector, Double)
   4 scaleAndNormSquared a [] = ([], 0)
   5 scaleAndNormSquared a (x:xs) = (a*x:recScale, x*x+recNormSquared)
   6   where (recScale, recNormSquared) = scaleAndNormSquared a xs

Now using the laziness of Haskell, and recursive binding, we can use scaleAndNormSquared to create a virtually one-pass normalization. We need to scale by the reciprocal of the square-root of normSquared. So we say exactly that.

   1 circNormalize :: Vector -> Vector
   2 circNormalize v = scaledVector
   3   where (scaledVector, normSquared) = scaleAndNormSquared (recip (sqrt normSquared)) v

Now using the laziness of Haskell, and recursive binding, we can use scaleAndNormSquared to create a virtually one-pass normalization. We need to scale by the reciprocal of the square-root of normSquared. So we say exactly that.

   1 circNormalize :: Vector -> Vector
   2 circNormalize v = scaledVector
   3   where (scaledVector, normSquared) = scaleAndNormSquared (recip (sqrt normSquared)) v

Formatting

italic bold typewriter

backtick typewriter (configurable)

bigger smaller

preformatted some more
and some more lines too

   1 def syntax(highlight):
   2     print "on"
   3     return None

   1   public void main(String[] args]){
   2      System.out.println("Hello world!");
   3   }

Linking

HelpOnEditing InterWiki

http://moinmoin.wikiwikiweb.de/ Python

someone@the.inter.net

An internal link that looks like normal text.

http://c2.com/sig/wiki.gif

Smileys

/!\ Alert

Lists

Bullet

Glossary

Term
Definition

Drawing

Heading 1

Heading 2

Heading 3

Heading 4

IRC Log test

   1 (23:18) <     jroes> ah
   2 (23:19) <     jroes> hm, i like the way {{{ works, but i was hoping the lines would wrap
   3 (23:21) -!- gpciceri [~gpciceri@host181-130.pool8248.interbusiness.it] has quit [Read error: 110 (Connection timed out)]
   4 (23:36) < ThomasWal> you could also write a parser or processor
   5 (23:38) <     jroes> i could?
   6 (23:38) <     jroes> would that require modification on the moin end though?
   7 (23:38) <     jroes> i cant change the wiki myself :x
   8 (23:39) < ThomasWal> parsers and processors are plugable
   9 (23:39) < ThomasWal> so you dont need to change the core code
  10 (23:40) < ThomasWal> you need to copy it to the wiki data directory though
  11 (23:40) <     jroes> well, what i meant to say was that i dont have access to the box running the wiki
  12 (23:40) < ThomasWal> then this is no option
  13 (23:40) <     jroes> yeah :/

roonk rezeptfrei kaufen Armee Russland Sixpack

WikiSandBox (last edited 04-09-2008 10:54:02 by p54ABD9F0)

Cocorico!WikiLicense