Skip to content

Instantly share code, notes, and snippets.

A quadratic space is a real vector space V with a quadratic form Q(x), e.g. V = R^n with Q as the squared length. The Clifford algebra Cl(V) of a quadratic space is the associative algebra that contains V and satisfies x^2 = Q(x) for all x in V. We're imposing by fiat that the square of a vector should be the quadratic form's value and seeing where it takes us. Treat x^2 = Q(x) as a symbolic rewriting rule that lets you replace x^2 or x x with Q(x) and vice versa whenever x is a vector. Beyond that Cl(V) satisfies the standard axioms of an algebra: it lets you multiply by scalars, it's associative and distributive, but not necessarily commutative.

Remarkably, this is all you need to derive everything about Clifford algebras.

Let me show you how easy it is to bootstrap the theory from nothing.

We know Cl(V) contains a copy of V. Since x^2 = Q(x) for all x, it must also contain a copy of some nonnegative reals.

@giuliohome
giuliohome / PageAjax2.aspx
Created November 2, 2018 18:55
Calling C# from JavaScript
protected async void Page_Load(object sender, EventArgs e)
{
test++;
if (!Page.IsPostBack)
{
if (Request.Form["method"] == "Test")
{
MyType[] obj = await Test(Request.Form["msg1"], Request.Form["msg2"]);
string json = new JavaScriptSerializer().Serialize(obj);
Response.Write(json);
@giuliohome
giuliohome / FP2TheMax.fs
Last active August 18, 2018 17:19
F# port of John A De Goes "FP to the max"
open System
type Eff<'Ctx, 'T> = 'Ctx -> 'T
type EffBuilder() =
member __.Return x : Eff<'Ctx,'T> =
fun _ -> x
member __.Bind(f : Eff<'Ctx, 'T>, g : 'T -> Eff<'Ctx, 'S>) : Eff<'Ctx, 'S> =
fun c -> g (f c) c
member __.Zero() : Eff<'Ctx, unit> =
@giuliohome
giuliohome / safetraversal.fs
Created August 9, 2018 14:12
more robust check
let rec bfs2robust (fanout: Map<'node, 'node seq> -> 'node -> 'node seq) (tree: Map<'node, 'node seq>) (node: 'node) : 'node seq =
let single = seq [node]
match fanout tree node with
| e when e = Seq.empty -> single
| s -> Seq.fold (fun acc item ->
bfs2robust fanout (tree |> Map.remove node) item
|> Seq.append acc) single s |> Seq.distinct
let rec bfs2 (fanout: Map<'node, 'node seq> -> 'node -> 'node seq) (tree: Map<'node, 'node seq>) (node: 'node) : 'node seq =
let single = seq [node]
match fanout tree node with
| e when e = Seq.empty -> single
| s -> Seq.fold (fun acc item ->
bfs2 fanout tree item
|> Seq.append acc) single s
@giuliohome
giuliohome / BindableTextBlock.cs
Last active December 18, 2020 08:27
TextBloacks with colours !!!
public class BindableTextBlock : TextBlock
{
public ObservableCollection<Inline> InlineList
{
get { return (ObservableCollection<Inline>)GetValue(InlineListProperty); }
set { SetValue(InlineListProperty, value); }
}
public static readonly DependencyProperty InlineListProperty =
DependencyProperty.Register("InlineList", typeof(ObservableCollection<Inline>), typeof(BindableTextBlock), new UIPropertyMetadata(null, OnPropertyChanged));
<DataGrid Grid.Column="2" ItemsSource="{Binding SelPayment.eur_invoices}" IsReadOnly="True" AutoGenerateColumns="False"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10" >
<DataGrid.Columns>
<DataGridTextColumn Header="Buy/Sell" Binding="{Binding buysell}" />
<DataGridTextColumn Header="Cpty Name" Binding="{Binding CptyName}" />
<DataGridTextColumn Header="Invoice Nr" Binding="{Binding InvoiceNr}" />
<DataGridTextColumn Header="Amount" Binding="{Binding amount, StringFormat=N}" />
<DataGridTextColumn Header="Curr" Binding="{Binding curr}" />
<DataGridTextColumn Header="Msg" Binding="{Binding ui.msg}" />
</DataGrid.Columns>
@giuliohome
giuliohome / model_v2.fs
Created August 2, 2018 11:01
Model with composition
type Back2UI() =
inherit SimpleViewModelBase()
let mutable _msg = ""
member this.msg
with get() = _msg
and set value =
_msg <- value
this.OnPropertyChanged(<@ this.msg @>)
type ActivePassive = Active | Passive
@giuliohome
giuliohome / view.xaml
Created August 2, 2018 10:58
UI binding from an array to a datagrid
<DataGrid Grid.Column="2" ItemsSource="{Binding SelPayment.eur_invoices}" IsReadOnly="True"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10" >
@giuliohome
giuliohome / model.fs
Created August 2, 2018 10:54
F# record type as business model
// business model
type Invoice = { CptyName: string; CptyNum: int; InvoiceNr: string; amount : decimal; curr: string; buysell: ActivePassive}
// array extraction from Excel with type provider
let ActiveInvoice =
ActiveInvoiceExcel.Data
|> Seq.map ( fun line -> { InvoiceNr = line.``Numero documento``; ... })
|> Seq.toArray