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
| using StaticArrays | |
| import StaticArrays.SUnitRange | |
| @noinline function inv2(a::StaticMatrix{4,4}) | |
| # See http://www.freevec.org/function/inverse_matrix_4x4_using_partitioning | |
| # Partition | |
| i1 = SUnitRange(1,2) | |
| i2 = SUnitRange(3,4) | |
| @inbounds P = a[i1,i1] |
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
| solve_divisor{T}(::Type{T},a,b,N) = solve_divisor(convert(T, a), convert(T, b), convert(T, N)) | |
| function solve_divisor{T}(a::T, b::T, N::T) | |
| #x = nextfloat(typemin(T)) | |
| x = T(1) | |
| while x < 2 #prevfloat(typemax(T)) | |
| if ((a*x)*N)/(x*N) == a && ((b*x)*N)/(x*N) == b | |
| return x | |
| end | |
| x = nextfloat(x) |
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 <stdio.h> | |
| #include <stdlib.h> | |
| int main() | |
| { | |
| FILE* f = fopen("AUSGeoid09_GDA94_V1.01_DOV.txt", "r"); | |
| if (!f || fscanf(f, "%*[^\n]\n") != 0) | |
| return 1; | |
| int hlen = 10; | |
| int hindex = 0; |
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
| module SimpleSymbolic | |
| immutable S{Ex} | |
| x::Ex | |
| end | |
| macro S(ex) | |
| Expr(:call, :S, Expr(:quote, ex)) | |
| end |
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
| module GeneratedTypes | |
| # First an example of a simple "generic" type | |
| immutable GenericImmutable{FieldNames, FieldTypes<:Tuple} | |
| fieldvalues::FieldTypes | |
| end | |
| @generated function getfield{FieldNames, FieldTypes, Name}(gi::GenericImmutable{FieldNames,FieldTypes},::Type{Val{Name}}) | |
| fieldnumber = findfirst(FieldNames, Name) | |
| fieldnumber > 0 || error("Field $name not found") |
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
| using DualNumbers | |
| # Solve the matrix system | |
| # | |
| # B = U'*M + M'*U | |
| # | |
| # for M where B is symmetric and U is upper triangular. This looks a bit like | |
| # the *-Sylvester equation, but has significantly more symmetry. | |
| function tri_ss_solve!{T<:Base.LinAlg.BlasFloat}(M::AbstractArray{T,2}, U::AbstractArray{T,2}, B::AbstractArray{T,2}) | |
| # This turns out to be a forward substitution algorithm in terms of the |
NewerOlder