This file contains hidden or 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
| #include <iostream> | |
| #include <iterator> | |
| #include <fstream> | |
| #include <algorithm> | |
| #include <iomanip> | |
| #include <complex> | |
| #include <cmath> | |
| double const pi = 4 * std::atan(1); |
This file contains hidden or 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
| angles = @(j) acos(linspace(-j,j,j*2+1)./(sqrt(j*(j+1)))); |
This file contains hidden or 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
| import numpy as np | |
| # numpy.dot | |
| # For 2-D arrays it is equivalent to matrix multiplication, and for | |
| # 1-D arrays to inner product of vectors (without complex conjugation). | |
| # Ex: np.dot([[1, 0], [0, 1]], [[4, 1], [2, 2]]) | |
| # numpy.vdot | |
| # The vdot(a, b) function handles complex numbers differently than dot(a, b). | |
| # If the first argument is complex the complex conjugate of the first argument is |
This file contains hidden or 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
| user=> (Long/toBinaryString (Double/doubleToLongBits 3.14)) | |
| "100000000001001000111101011100001010001111010111000010100011111" | |
| user=> (map #(println (apply str (drop 10 %1))) (map #(Long/toBinaryString (Double/doubleToLongBits %1)) (range 1 2 0.05))) | |
| 0000000000000000000000000000000000000000000000000000 | |
| 0000110011001100110011001100110011001100110011001101 | |
| 0001100110011001100110011001100110011001100110011010 | |
| 0010011001100110011001100110011001100110011001100111 | |
| 0011001100110011001100110011001100110011001100110100 | |
| 0100000000000000000000000000000000000000000000000001 |
This file contains hidden or 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
| (* testcont.sml | |
| * | |
| * Copyright (c) 2014. Johan Astborg. | |
| * | |
| * This illustrates the use of continuation-passing style (CPS) | |
| * applied to Standard ML and more specific MLton together with | |
| * infix operators to achieve a stackless programming style. | |
| * | |
| * See "http://mlton.org/MLtonCont" for details. | |
| *) |
This file contains hidden or 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
| #!/usr/local/bin/zsh | |
| pkg install subversion | |
| pkg install `pkg search gcc5` | |
| cd /usr/ports/lang | |
| svn co https://svn0.us-east.freebsd.org/ports/head/lang/moscow_ml moscow_ml | |
| make patch | |
| pkg install `pkg search gcc5` | |
| make CC="gcc5" |
This file contains hidden or 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
| %% Matrix Theory - Assignment 1 | |
| % Johan Astborg, HT14 | |
| % joastbg@gmail.com | |
| %% Illustrates the usage | |
| % Feel free to change the test matrix | |
| function draft() | |
| % Test matrices | |
This file contains hidden or 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
| #include <iostream> | |
| #include <iterator> | |
| #include <fstream> | |
| #include <algorithm> | |
| int main () { | |
| std::ifstream infile("example.txt"); | |
| std::istream_iterator<double> iit (infile); |
This file contains hidden or 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
| // e^(-r*sqrt(t/n)) using some x86 tricks | |
| float _fexpbin(float vol, float t) | |
| { | |
| float ret; | |
| __asm | |
| { | |
| fld t | |
| fsqrt | |
| fldln2 | |
| fdiv |
This file contains hidden or 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
| #include <mpi.h> | |
| int main(int argc, char** argv) | |
| { | |
| // Initialize the MPI environment | |
| MPI_Init(NULL, NULL); | |
| // Get the number of processes | |
| int world_size; | |
| MPI_Comm_size(MPI_COMM_WORLD, &world_size); |