Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7154f97
commit 695e50d
Showing
5 changed files
with
47 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
all: main tests | ||
# Makefile for Homework 6 | ||
# by Mark <andrus@uchicago.edu> | ||
|
||
main: main.hs util.hs | ||
# We must refer to iconv in /usr/lib | ||
ghc -L/usr/lib main.hs -o main -fno-cse | ||
ghc = ghc | ||
flags = -O2 | ||
|
||
tests: tests.hs util.hs | ||
ghc -L/usr/lib -O2 tests.hs -o tests | ||
# NOTE: the following hack is a consequence of GHC for OS X being compiled against the libiconv in | ||
# `/usr/lib` | ||
extra_libs = -L/usr/lib | ||
|
||
bins = main tests | ||
deps = Utils.hs | ||
|
||
all: $(bins) | ||
|
||
main: Main.hs $(deps) | ||
$(ghc) $(extra_libs) $(flags) $< -o $@ | ||
|
||
tests: tests.hs $(deps) | ||
$(ghc) $(extra_libs) $(flags) $< -o $@ | ||
|
||
.PHONY: all clean | ||
|
||
clean: | ||
rm -f *.hi *.o main tests | ||
rm -f *.hi *.o $(bins) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
|
||
module Utils | ||
( isSymmetric | ||
, vNormalize | ||
, mNormalize | ||
) where | ||
|
||
import Numeric.LinearAlgebra | ||
|
||
isSymmetric :: (Element a, Eq a) => Matrix a -> Bool | ||
isSymmetric a = toLists a == toLists (trans a) | ||
|
||
vNormalize :: Vector Double -> Vector Double | ||
vNormalize v = recip (norm2 v) `scale` v | ||
|
||
mNormalize :: Matrix Double -> Matrix Double | ||
mNormalize m = recip (det m) `scale` m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters