From f94dbac514db2bf77083efc1b5920c3583fa03de Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Thu, 11 Jun 2026 15:36:58 +0200 Subject: [PATCH 01/20] Constructors for dmat, smat, dvec, and svec --- Project.toml | 5 +++- src/BLASFEO.jl | 9 +++++- src/mats.jl | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/show.jl | 21 ++++++++++++++ src/vecs.jl | 70 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 src/mats.jl create mode 100644 src/show.jl create mode 100644 src/vecs.jl diff --git a/Project.toml b/Project.toml index b901066..8711a32 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,10 @@ name = "BLASFEO" uuid = "2d913c56-f67c-11e9-3afb-9119491b9f4c" -authors = ["Ian McInerney", "Imperial College London"] version = "0.1.0" +authors = ["Ian McInerney", "Imperial College London"] + +[deps] +blasfeo_jll = "6b574d4a-bb57-5a4b-b7e6-1c794c903646" [compat] julia = "1" diff --git a/src/BLASFEO.jl b/src/BLASFEO.jl index e7d76f7..3fe7bae 100644 --- a/src/BLASFEO.jl +++ b/src/BLASFEO.jl @@ -1,5 +1,12 @@ module BLASFEO +using blasfeo_jll +include("vecs.jl") +include("mats.jl") +include("show.jl") -greet() = print("Hello World!") +# Vectors +export BlasfeoDvec, BlasfeoSvec +# Matrices +export BlasfeoDmat, BlasfeoSmat end # module diff --git a/src/mats.jl b/src/mats.jl new file mode 100644 index 0000000..4a73171 --- /dev/null +++ b/src/mats.jl @@ -0,0 +1,78 @@ +# NOTE(@anton): Both of these structs are treated as mutable and Julia manages their +# lifetimes itself. Blasfeo also offers a way to preallocate memory but +# we still need the bitstype struct and to manage that memory so I think +# may as well use `blasfeo_allocate_*` and `blasfeo_free_*` + +# bits clone of panel major `blasfeo_dmat` +# blasfeo_jll compiles with PANELMAJ so we only need this one and not the column major version +mutable struct BlasfeoDmat + const mem::Ptr{Cdouble} # pointer to passed chunk of memory + const pA::Ptr{Cdouble} # pointer to a pm*pn array of doubles, the first is aligned to cache line size + const dA::Ptr{Cdouble} # pointer to a min(m,n) (or max???) array of doubles + const m::Cint # rows + const n::Cint # cols + const pm::Cint # packed number or rows + const cn::Cint # packed number or cols + const use_dA::Cint # flag to tell if dA can be used + const memsize::Cint # size of needed memory + + function BlasfeoDmat(m::Int,n::Int) + mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + @ccall blasfeo.blasfeo_allocate_dmat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoDmat})::Cvoid + function destructor(this) + @ccall blasfeo.blasfeo_free_dmat(pointer_from_objref(this)::Ptr{BlasfeoDmat})::Cvoid + end + return finalizer(destructor, mat) + end + + function BlasfeoDmat(other::Matrix{Cdouble}) + mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + m,n = size(other) + @ccall blasfeo.blasfeo_allocate_dmat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoDmat})::Cvoid + function destructor(this) + @ccall blasfeo.blasfeo_free_dmat(pointer_from_objref(this)::Ptr{BlasfeoDmat})::Cvoid + end + @ccall blasfeo.blasfeo_pack_dmat(m::Cint, n::Cint, + other::Ptr{Cdouble}, m::Cint, + pointer_from_objref(mat)::Ptr{BlasfeoDmat}, + 0::Cint, 0::Cint)::Cvoid + return finalizer(destructor, mat) + end +end + +# bits clone of panel major `blasfeo_smat` +# blasfeo_jll compiles with PANELMAJ so we only need this one and not the column major version +mutable struct BlasfeoSmat + const mem::Ptr{Cfloat} # pointer to passed chunk of memory + const pA::Ptr{Cfloat} # pointer to a pm*pn array of doubles, the first is aligned to cache line size + const dA::Ptr{Cfloat} # pointer to a min(m,n) (or max???) array of doubles + const m::Cint # rows + const n::Cint # cols + const pm::Cint # packed number or rows + const cn::Cint # packed number or cols + const use_dA::Cint # flag to tell if dA can be used + const memsize::Cint # size of needed memory + + function BlasfeoSmat(m::Int,n::Int) + mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + @ccall blasfeo.blasfeo_allocate_smat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoSmat})::Cvoid + function destructor(this) + @ccall blasfeo.blasfeo_free_smat(pointer_from_objref(this)::Ptr{BlasfeoSmat})::Cvoid + end + return finalizer(destructor, mat) + end + + function BlasfeoSmat(other::Matrix{Cfloat}) + mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + m,n = size(other) + @ccall blasfeo.blasfeo_allocate_smat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoSmat})::Cvoid + function destructor(this) + @ccall blasfeo.blasfeo_free_smat(pointer_from_objref(this)::Ptr{BlasfeoSmat})::Cvoid + end + @ccall blasfeo.blasfeo_pack_smat(m::Cint, n::Cint, + other::Ptr{Cdouble}, m::Cint, + pointer_from_objref(mat)::Ptr{BlasfeoSmat}, + 0::Cint, 0::Cint)::Cvoid + return finalizer(destructor, mat) + end +end diff --git a/src/show.jl b/src/show.jl new file mode 100644 index 0000000..91eb527 --- /dev/null +++ b/src/show.jl @@ -0,0 +1,21 @@ +# TODO(@anton) mxn or nxm + +function Base.show(io::IO, mat::BlasfeoDmat) + println("$(mat.m)x$(mat.n) BlasfeoDmat:") + @ccall blasfeo.blasfeo_print_dmat(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoDmat}, 0::Cint, 0::Cint)::Cvoid +end + +function Base.show(io::IO, mat::BlasfeoSmat) + println("$(mat.m)x$(mat.n) BlasfeoSmat:") + @ccall blasfeo.blasfeo_print_smat(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoSmat}, 0::Cint, 0::Cint)::Cvoid +end + +function Base.show(io::IO, vec::BlasfeoDvec) + println("$(vec.m)-element BlasfeoDvec:") + @ccall blasfeo.blasfeo_print_dvec(vec.m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec}, 0::Cint)::Cvoid +end + +function Base.show(io::IO, vec::BlasfeoSvec) + println("$(vec.m)-element BlasfeoSvec:") + @ccall blasfeo.blasfeo_print_svec(vec.m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec}, 0::Cint)::Cvoid +end diff --git a/src/vecs.jl b/src/vecs.jl new file mode 100644 index 0000000..771809b --- /dev/null +++ b/src/vecs.jl @@ -0,0 +1,70 @@ +# NOTE(@anton): Both of these structs are treated as mutable and Julia manages their +# lifetimes itself. Blasfeo also offers a way to preallocate memory but +# we still need the bitstype struct and to manage that memory so I think +# may as well use `blasfeo_allocate_*` and `blasfeo_free_*` + +# bits clone of panel major `blasfeo_dvec` +mutable struct BlasfeoDvec + mem::Ptr{Cdouble} # pointer to passed chunk of memory + pa::Ptr{Cdouble} # pointer to a pm array of doubles, the first is aligned to cache line size + m::Cint # size + pm::Cint # packed size + memsize::Cint # size of needed memory + + function BlasfeoDvec(m::Int) + vec = new(C_NULL,C_NULL,0,0,0) + @ccall blasfeo.blasfeo_allocate_dvec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec})::Cvoid + function destructor(this) + @ccall blasfeo.blasfeo_free_dvec(pointer_from_objref(this)::Ptr{BlasfeoDvec})::Cvoid + end + return finalizer(destructor, vec) + end + + function BlasfeoDvec(other::Vector{Cdouble}) + vec = new(C_NULL,C_NULL,0,0,0) + @ccall blasfeo.blasfeo_allocate_dvec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec})::Cvoid + function destructor(this) + @ccall blasfeo.blasfeo_free_dvec(pointer_from_objref(this)::Ptr{BlasfeoDvec})::Cvoid + end + + @ccall blasfeo.blasfeo_pack_dvec(m::Cint, + other::Ptr{Cdouble}, 1::Cint, + pointer_from_objref(vec)::Ptr{BlasfeoDvec}, + 0::Cint)::Cvoid + + return finalizer(destructor, vec) + end +end + +# bits clone of panel major `blasfeo_svec` +mutable struct BlasfeoSvec + mem::Ptr{Cfloat} # pointer to passed chunk of memory + pa::Ptr{Cfloat} # pointer to a pm array of floats, the first is aligned to cache line size + m::Cint # size + pm::Cint # packed size + memsize::Cint # size of needed memory + + function BlasfeoSvec(m::Int,n::Int) + vec = new(C_NULL,C_NULL,0,0,0) + @ccall blasfeo.blasfeo_allocate_svec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec})::Cvoid + function destructor(this) + @ccall blasfeo.blasfeo_free_svec(pointer_from_objref(this)::Ptr{BlasfeoSvec})::Cvoid + end + return finalizer(destructor, vec) + end + + function BlasfeoSvec(other::Vector{Cfloat}) + vec = new(C_NULL,C_NULL,0,0,0) + @ccall blasfeo.blasfeo_allocate_svec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec})::Cvoid + function destructor(this) + @ccall blasfeo.blasfeo_free_svec(pointer_from_objref(this)::Ptr{BlasfeoSvec})::Cvoid + end + + @ccall blasfeo.blasfeo_pack_svec(m::Cint, + other::Ptr{Cfloat}, 1::Cint, + pointer_from_objref(vec)::Ptr{BlasfeoSvec}, + 0::Cint)::Cvoid + + return finalizer(destructor, vec) + end +end From c9c6438d91c892b3a88118fac8c74490d9ce2f39 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Thu, 11 Jun 2026 18:00:44 +0200 Subject: [PATCH 02/20] working show and beginnings of basic AbstractMatrix/Vector work --- src/mats.jl | 22 ++++++++++++++++++---- src/show.jl | 45 +++++++++++++++++++++++++++++++++++++++++---- src/vecs.jl | 12 ++++++------ 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/src/mats.jl b/src/mats.jl index 4a73171..89a084c 100644 --- a/src/mats.jl +++ b/src/mats.jl @@ -5,7 +5,7 @@ # bits clone of panel major `blasfeo_dmat` # blasfeo_jll compiles with PANELMAJ so we only need this one and not the column major version -mutable struct BlasfeoDmat +mutable struct BlasfeoDmat <: AbstractMatrix{Cdouble} const mem::Ptr{Cdouble} # pointer to passed chunk of memory const pA::Ptr{Cdouble} # pointer to a pm*pn array of doubles, the first is aligned to cache line size const dA::Ptr{Cdouble} # pointer to a min(m,n) (or max???) array of doubles @@ -16,7 +16,7 @@ mutable struct BlasfeoDmat const use_dA::Cint # flag to tell if dA can be used const memsize::Cint # size of needed memory - function BlasfeoDmat(m::Int,n::Int) + function BlasfeoDmat(m::Integer,n::Integer) mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) @ccall blasfeo.blasfeo_allocate_dmat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoDmat})::Cvoid function destructor(this) @@ -42,7 +42,7 @@ end # bits clone of panel major `blasfeo_smat` # blasfeo_jll compiles with PANELMAJ so we only need this one and not the column major version -mutable struct BlasfeoSmat +mutable struct BlasfeoSmat <: AbstractMatrix{Cfloat} const mem::Ptr{Cfloat} # pointer to passed chunk of memory const pA::Ptr{Cfloat} # pointer to a pm*pn array of doubles, the first is aligned to cache line size const dA::Ptr{Cfloat} # pointer to a min(m,n) (or max???) array of doubles @@ -53,7 +53,7 @@ mutable struct BlasfeoSmat const use_dA::Cint # flag to tell if dA can be used const memsize::Cint # size of needed memory - function BlasfeoSmat(m::Int,n::Int) + function BlasfeoSmat(m::Integer,n::Integer) mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) @ccall blasfeo.blasfeo_allocate_smat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoSmat})::Cvoid function destructor(this) @@ -76,3 +76,17 @@ mutable struct BlasfeoSmat return finalizer(destructor, mat) end end + +# basic matrix operations +# TODO(@anton) Do we _need_ such tight typing on setindex? +for (type,flag) in [ + (:BlasfeoDmat, :d), + (:BlasfeoSmat, :s), + ] + @eval Base.size(A::$type) = (A.m, A.n) + blasfeo_geex1 = Symbol(:blasfeo_, flag, :geex1) + @eval Base.getindex(A::$type, I::Vararg{Int, 2}) = @ccall blasfeo.$blasfeo_geex1(pointer_from_objref(A)::Ptr{$type}, (I[1]-1)::Cint, (I[2]-1)::Cint)::eltype($type) + @eval Base.similar(A::$type) = $type(A.m, A.n) + @eval Base.similar(A::$type,dims::Dims{2}) = $type(dims...) + +end diff --git a/src/show.jl b/src/show.jl index 91eb527..add7b1f 100644 --- a/src/show.jl +++ b/src/show.jl @@ -1,21 +1,58 @@ # TODO(@anton) mxn or nxm -function Base.show(io::IO, mat::BlasfeoDmat) +function Base.show(io, mat::BlasfeoDmat) println("$(mat.m)x$(mat.n) BlasfeoDmat:") @ccall blasfeo.blasfeo_print_dmat(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoDmat}, 0::Cint, 0::Cint)::Cvoid end -function Base.show(io::IO, mat::BlasfeoSmat) +function Base.show(io, mat::BlasfeoSmat) println("$(mat.m)x$(mat.n) BlasfeoSmat:") @ccall blasfeo.blasfeo_print_smat(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoSmat}, 0::Cint, 0::Cint)::Cvoid end -function Base.show(io::IO, vec::BlasfeoDvec) +function Base.show(io, vec::BlasfeoDvec) println("$(vec.m)-element BlasfeoDvec:") @ccall blasfeo.blasfeo_print_dvec(vec.m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec}, 0::Cint)::Cvoid end -function Base.show(io::IO, vec::BlasfeoSvec) +function Base.show(io, vec::BlasfeoSvec) println("$(vec.m)-element BlasfeoSvec:") @ccall blasfeo.blasfeo_print_svec(vec.m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec}, 0::Cint)::Cvoid end + +# TODO(@anton) This is probably not needed, we just need `print_matrix`? this is horribly documented. +for (type,shortname) in [ + (:BlasfeoDvec, :dvec), + (:BlasfeoSvec, :svec), + ] + printer = Symbol(:blasfeo_print_,shortname) + @eval begin + function Base.show(io::IO, ::MIME"text/plain", vec::$type) + println("$(vec.m)-element $($type):") + @ccall blasfeo.$printer(vec.m::Cint, pointer_from_objref(vec)::Ptr{$type}, 0::Cint)::Cvoid + end + + function Base.show(io::IO, vec::$type) + println("$(vec.m)-element $($type):") + @ccall blasfeo.$printer(vec.m::Cint, pointer_from_objref(vec)::Ptr{$type}, 0::Cint)::Cvoid + end + end +end + +for (type,shortname) in [ + (:BlasfeoDmat, "dmat"), + (:BlasfeoSmat, "smat"), + ] + printer = Symbol(:blasfeo_print_,shortname) + @eval begin + function Base.show(io::IO, ::MIME"text/plain", mat::$type) + println("$(mat.m)x$(mat.n) $($type):") + @ccall blasfeo.$printer(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{$type}, 0::Cint, 0::Cint)::Cvoid + end + + function Base.show(io::IO, mat::$type) + println("$(mat.m)x$(mat.n) $($type):") + @ccall blasfeo.$printer(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{$type}, 0::Cint, 0::Cint)::Cvoid + end + end +end diff --git a/src/vecs.jl b/src/vecs.jl index 771809b..4fa1356 100644 --- a/src/vecs.jl +++ b/src/vecs.jl @@ -4,7 +4,7 @@ # may as well use `blasfeo_allocate_*` and `blasfeo_free_*` # bits clone of panel major `blasfeo_dvec` -mutable struct BlasfeoDvec +mutable struct BlasfeoDvec <: AbstractVector{Cdouble} mem::Ptr{Cdouble} # pointer to passed chunk of memory pa::Ptr{Cdouble} # pointer to a pm array of doubles, the first is aligned to cache line size m::Cint # size @@ -22,12 +22,12 @@ mutable struct BlasfeoDvec function BlasfeoDvec(other::Vector{Cdouble}) vec = new(C_NULL,C_NULL,0,0,0) - @ccall blasfeo.blasfeo_allocate_dvec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec})::Cvoid + @ccall blasfeo.blasfeo_allocate_dvec(length(other)::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec})::Cvoid function destructor(this) @ccall blasfeo.blasfeo_free_dvec(pointer_from_objref(this)::Ptr{BlasfeoDvec})::Cvoid end - @ccall blasfeo.blasfeo_pack_dvec(m::Cint, + @ccall blasfeo.blasfeo_pack_dvec(vec.m::Cint, other::Ptr{Cdouble}, 1::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec}, 0::Cint)::Cvoid @@ -37,7 +37,7 @@ mutable struct BlasfeoDvec end # bits clone of panel major `blasfeo_svec` -mutable struct BlasfeoSvec +mutable struct BlasfeoSvec <: AbstractVector{Cfloat} mem::Ptr{Cfloat} # pointer to passed chunk of memory pa::Ptr{Cfloat} # pointer to a pm array of floats, the first is aligned to cache line size m::Cint # size @@ -55,12 +55,12 @@ mutable struct BlasfeoSvec function BlasfeoSvec(other::Vector{Cfloat}) vec = new(C_NULL,C_NULL,0,0,0) - @ccall blasfeo.blasfeo_allocate_svec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec})::Cvoid + @ccall blasfeo.blasfeo_allocate_svec(length(other)::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec})::Cvoid function destructor(this) @ccall blasfeo.blasfeo_free_svec(pointer_from_objref(this)::Ptr{BlasfeoSvec})::Cvoid end - @ccall blasfeo.blasfeo_pack_svec(m::Cint, + @ccall blasfeo.blasfeo_pack_svec(vec.m::Cint, other::Ptr{Cfloat}, 1::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec}, 0::Cint)::Cvoid From 182d587a35ca233a579e0e3e48ff101c1721a5b4 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Fri, 12 Jun 2026 08:11:08 +0200 Subject: [PATCH 03/20] basic operations and testing basic operations --- src/mats.jl | 34 ++++++++++++++++++++++++++++++- src/vecs.jl | 50 ++++++++++++++++++++++++++++++++++++++++++++-- test/mat/basics.jl | 27 +++++++++++++++++++++++++ test/runtests.jl | 5 ++--- test/vec/basics.jl | 27 +++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 test/mat/basics.jl create mode 100644 test/vec/basics.jl diff --git a/src/mats.jl b/src/mats.jl index 89a084c..36c6fb5 100644 --- a/src/mats.jl +++ b/src/mats.jl @@ -78,15 +78,47 @@ mutable struct BlasfeoSmat <: AbstractMatrix{Cfloat} end # basic matrix operations -# TODO(@anton) Do we _need_ such tight typing on setindex? for (type,flag) in [ (:BlasfeoDmat, :d), (:BlasfeoSmat, :s), ] + # size @eval Base.size(A::$type) = (A.m, A.n) + + # getindex blasfeo_geex1 = Symbol(:blasfeo_, flag, :geex1) @eval Base.getindex(A::$type, I::Vararg{Int, 2}) = @ccall blasfeo.$blasfeo_geex1(pointer_from_objref(A)::Ptr{$type}, (I[1]-1)::Cint, (I[2]-1)::Cint)::eltype($type) + + # setindex! + blasfeo_gein1 = Symbol(:blasfeo_, flag, :gein1) + @eval Base.setindex!(A::$type, v::T, I::Vararg{Int, 2}) where {T <: Real} = @ccall blasfeo.$blasfeo_gein1(v::eltype($type),pointer_from_objref(A)::Ptr{$type}, (I[1]-1)::Cint, (I[2]-1)::Cint)::eltype($type) + + # similar @eval Base.similar(A::$type) = $type(A.m, A.n) @eval Base.similar(A::$type,dims::Dims{2}) = $type(dims...) + # copy + blasfeo_gecp = Symbol(:blasfeo_, flag, :gecp) + @eval function copy(A::$type) + B = similar(A) + A_ptr = pointer_from_objref(A) + B_ptr = pointer_from_objref(B) + @ccall blasfeo.blasfeo_gecp( + A.m::Cint, A.n::Cint, + A_ptr::Ptr{$type}, 0::Cint, 0::Cint, + B_ptr::Ptr{$type}, 0::Cint, 0::Cint + )::Cvoid + return B + end + + # fill + blasfeo_gese = Symbol(:blasfeo_, flag, :gese) + @eval function fill(A::$type, b::T) where {T <: Real} + A_ptr = pointer_from_objref(A) + @ccall blasfeo.blasfeo_gese( + A.m::Cint, A.n::Cint, + b::eltype($type), + A_ptr::Ptr{$type}, 0::Cint, 0::Cint, + )::Cvoid + end end diff --git a/src/vecs.jl b/src/vecs.jl index 4fa1356..7384649 100644 --- a/src/vecs.jl +++ b/src/vecs.jl @@ -11,7 +11,7 @@ mutable struct BlasfeoDvec <: AbstractVector{Cdouble} pm::Cint # packed size memsize::Cint # size of needed memory - function BlasfeoDvec(m::Int) + function BlasfeoDvec(m::T) where {T <: Integer} vec = new(C_NULL,C_NULL,0,0,0) @ccall blasfeo.blasfeo_allocate_dvec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec})::Cvoid function destructor(this) @@ -44,7 +44,7 @@ mutable struct BlasfeoSvec <: AbstractVector{Cfloat} pm::Cint # packed size memsize::Cint # size of needed memory - function BlasfeoSvec(m::Int,n::Int) + function BlasfeoSvec(m::T) where {T <: Integer} vec = new(C_NULL,C_NULL,0,0,0) @ccall blasfeo.blasfeo_allocate_svec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec})::Cvoid function destructor(this) @@ -68,3 +68,49 @@ mutable struct BlasfeoSvec <: AbstractVector{Cfloat} return finalizer(destructor, vec) end end + +# basic vector operations +for (type,flag) in [ + (:BlasfeoDvec, :d), + (:BlasfeoSvec, :s), + ] + # size + @eval Base.size(A::$type) = (A.m,) + + # getindex + blasfeo_vecex1 = Symbol(:blasfeo_, flag, :vecex1) + @eval Base.getindex(A::$type, I::Vararg{Int, 1}) = @ccall blasfeo.$blasfeo_vecex1(pointer_from_objref(A)::Ptr{$type}, (I[1]-1)::Cint)::eltype($type) + + # setindex! + blasfeo_vecin1 = Symbol(:blasfeo_, flag, :vecin1) + @eval Base.setindex!(A::$type, v::T, I::Vararg{Int, 1}) where {T <: Real} = @ccall blasfeo.$blasfeo_vecin1(v::eltype($type),pointer_from_objref(A)::Ptr{$type}, (I[1]-1)::Cint)::eltype($type) + + # similar + @eval Base.similar(A::$type) = $type(A.m) + @eval Base.similar(A::$type,dims::Dims{1}) = $type(dims...) + + # copy + blasfeo_veccp = Symbol(:blasfeo_, flag, :veccp) + @eval function copy(A::$type) + B = similar(A) + A_ptr = pointer_from_objref(A) + B_ptr = pointer_from_objref(B) + @ccall blasfeo.blasfeo_veccp( + A.m::Cint, + A_ptr::Ptr{$type}, 0::Cint, + B_ptr::Ptr{$type}, 0::Cint, + )::Cvoid + return B + end + + # fill + blasfeo_vecse = Symbol(:blasfeo_, flag, :vecse) + @eval function fill(A::$type, b::T) where {T <: Real} + A_ptr = pointer_from_objref(A) + @ccall blasfeo.blasfeo_vecse( + A.m::Cint, + b::eltype($type), + A_ptr::Ptr{$type}, 0::Cint, + )::Cvoid + end +end diff --git a/test/mat/basics.jl b/test/mat/basics.jl new file mode 100644 index 0000000..d8b1e02 --- /dev/null +++ b/test/mat/basics.jl @@ -0,0 +1,27 @@ +@testset "Matrix Basic Operations" begin + @testset for MAT in (BlasfeoDmat, BlasfeoSmat) + A = rand(eltype(MAT), 100, 100) + A_blasfeo = MAT(A) + @test A == A_blasfeo + @test A[10,20] == A_blasfeo[10,20] + + A[10,20] = 30.0; A_blasfeo[10,20] = 30.0 + A[20,30] = 50; A_blasfeo[20,30] = 50 + @test A == A_blasfeo + + B_blasfeo = similar(A_blasfeo) + @test size(A_blasfeo) == size(B_blasfeo) + # Note(@anton) Blasfeo _always_ clears memory. + @test A_blasfeo != B_blasfeo + + C_blasfeo = copy(A_blasfeo) + @test A_blasfeo == C_blasfeo + + C_blasfeo[15,15] = 30.0 + @test C_blasfeo[15,15] == 30.0 + @test A_blasfeo != C_blasfeo + + fill!(C_blasfeo, 100.0) + @test all(C_blasfeo .== 100.0) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index f3ad109..63df0b2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,5 @@ using BLASFEO using Test -@testset "BLASFEO.jl" begin - # Write your own tests here. -end +include("mat/basics.jl") +include("vec/basics.jl") diff --git a/test/vec/basics.jl b/test/vec/basics.jl new file mode 100644 index 0000000..90084ee --- /dev/null +++ b/test/vec/basics.jl @@ -0,0 +1,27 @@ +@testset "Vector Basic Operations" begin + @testset for VEC in (BlasfeoDvec, BlasfeoSvec) + A = rand(eltype(VEC), 100) + A_blasfeo = VEC(A) + @test A == A_blasfeo + @test A[10] == A_blasfeo[10] + + A[10] = 10.0; A_blasfeo[10] = 10.0 + A[20] = 20; A_blasfeo[20] = 20 + @test A == A_blasfeo + + B_blasfeo = similar(A_blasfeo) + @test size(A_blasfeo) == size(B_blasfeo) + # Note(@anton) Blasfeo _always_ clears memory. + @test A_blasfeo != B_blasfeo + + C_blasfeo = copy(A_blasfeo) + @test A_blasfeo == C_blasfeo + + C_blasfeo[15] = 15.0 + @test C_blasfeo[15] == 15.0 + @test A_blasfeo != C_blasfeo + + fill!(C_blasfeo, 100.0) + @test all(C_blasfeo .== 100.0) + end +end From 49d11ce213d2256e3db4a2f893b46a3f3151331a Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Fri, 12 Jun 2026 18:18:05 +0200 Subject: [PATCH 04/20] start with lvl1 blas operations --- Project.toml | 2 ++ src/BLASFEO.jl | 5 ++++ src/level1.jl | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/mats.jl | 40 +++++++++++++++++++++++---- src/vecs.jl | 11 ++++---- 5 files changed, 123 insertions(+), 10 deletions(-) create mode 100644 src/level1.jl diff --git a/Project.toml b/Project.toml index 8711a32..01e1db6 100644 --- a/Project.toml +++ b/Project.toml @@ -4,9 +4,11 @@ version = "0.1.0" authors = ["Ian McInerney", "Imperial College London"] [deps] +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" blasfeo_jll = "6b574d4a-bb57-5a4b-b7e6-1c794c903646" [compat] +LinearAlgebra = "1.12.0" julia = "1" [extras] diff --git a/src/BLASFEO.jl b/src/BLASFEO.jl index 3fe7bae..d32c6ed 100644 --- a/src/BLASFEO.jl +++ b/src/BLASFEO.jl @@ -1,12 +1,17 @@ module BLASFEO +using LinearAlgebra using blasfeo_jll include("vecs.jl") include("mats.jl") include("show.jl") +include("level1.jl") # Vectors export BlasfeoDvec, BlasfeoSvec # Matrices export BlasfeoDmat, BlasfeoSmat +# Level 1 +export axpy, axpby + end # module diff --git a/src/level1.jl b/src/level1.jl new file mode 100644 index 0000000..a9fc235 --- /dev/null +++ b/src/level1.jl @@ -0,0 +1,75 @@ +for (type,flag) in [ + (:BlasfeoDvec, :d), + (:BlasfeoSvec, :s), + ] + # dot + blasfeo_dot = Symbol(:blasfeo_, flag, :dot) + @eval function LinearAlgebra.dot(a::$type, b::$type) + a_ptr=pointer_from_objref(a) + b_ptr=pointer_from_objref(b) + @ccall blasfeo.$blasfeo_dot( + a.m::Cint, a_ptr::Ptr{$type}, 0::Cint, + b_ptr::Ptr{$type}, 0::Cint, + )::eltype($type) + end + + # axpy! + blasfeo_axpy = Symbol(:blasfeo_, flag, :axpy) + @eval function LinearAlgebra.axpy!(α::T, x::$type, y::$type) where {T <: Real} + x_ptr=pointer_from_objref(x) + y_ptr=pointer_from_objref(y) + @ccall blasfeo.$blasfeo_axpy( + x.m::Cint, + α::Cdouble, x_ptr::Ptr{$type}, 0::Cint, + y_ptr::Ptr{$type}, 0::Cint, + y_ptr::Ptr{$type}, 0::Cint, + )::Cvoid + return y + end + + # 3 arg axpby + @eval function axpy(α::T, x::$type, y::$type, z::$type) where {T <: Real} + x_ptr=pointer_from_objref(x) + y_ptr=pointer_from_objref(y) + z_ptr=pointer_from_objref(z) + @ccall blasfeo.$blasfeo_axpy( + x.m::Cint, + α::Cdouble, x_ptr::Ptr{$type}, 0::Cint, + y_ptr::Ptr{$type}, 0::Cint, + z_ptr::Ptr{$type}, 0::Cint, + )::Cvoid + return z + end + + # axpby + blasfeo_axpby = Symbol(:blasfeo_, flag, :axpby) + @eval function LinearAlgebra.axpby!(α::T1, x::$type, β::T2, y::$type) where {T1 <: Real, T2 <: Real} + x_ptr=pointer_from_objref(x) + y_ptr=pointer_from_objref(y) + @ccall blasfeo.$blasfeo_axpby( + a.m::Cint, + α::Cdouble, x_ptr::Ptr{$type}, 0::Cint, + β::Cdouble, y_ptr::Ptr{$type}, 0::Cint, + y_ptr::Ptr{$type}, 0::Cint, + )::Cvoid + return y + end + + # 3 arg axpby + blasfeo_axpby = Symbol(:blasfeo_, flag, :axpby) + @eval function axpby(α::T1, x::$type, β::T2, y::$type, z::$type) where {T1 <: Real, T2 <: Real} + x_ptr=pointer_from_objref(x) + y_ptr=pointer_from_objref(y) + z_ptr=pointer_from_objref(z) + @ccall blasfeo.$blasfeo_axpby( + x.m::Cint, + α::Cdouble, x_ptr::Ptr{$type}, 0::Cint, + β::Cdouble, y_ptr::Ptr{$type}, 0::Cint, + z_ptr::Ptr{$type}, 0::Cint, + )::Cvoid + return z + end + + # :* + #@eval function Base.:* +end diff --git a/src/mats.jl b/src/mats.jl index 36c6fb5..126db22 100644 --- a/src/mats.jl +++ b/src/mats.jl @@ -99,11 +99,11 @@ for (type,flag) in [ # copy blasfeo_gecp = Symbol(:blasfeo_, flag, :gecp) - @eval function copy(A::$type) + @eval function Base.copy(A::$type) B = similar(A) A_ptr = pointer_from_objref(A) B_ptr = pointer_from_objref(B) - @ccall blasfeo.blasfeo_gecp( + @ccall blasfeo.$blasfeo_gecp( A.m::Cint, A.n::Cint, A_ptr::Ptr{$type}, 0::Cint, 0::Cint, B_ptr::Ptr{$type}, 0::Cint, 0::Cint @@ -111,14 +111,44 @@ for (type,flag) in [ return B end - # fill + # fill! blasfeo_gese = Symbol(:blasfeo_, flag, :gese) - @eval function fill(A::$type, b::T) where {T <: Real} + @eval function Base.fill!(A::$type, b::T) where {T <: Real} A_ptr = pointer_from_objref(A) - @ccall blasfeo.blasfeo_gese( + @ccall blasfeo.$blasfeo_gese( A.m::Cint, A.n::Cint, b::eltype($type), A_ptr::Ptr{$type}, 0::Cint, 0::Cint, )::Cvoid + return A + end + + # convert to Matrix and back + # TODO(@anton) maybe the performance overhead of this means maybe we want only explicit constructors? + blasfeo_unpack = Symbol(:blasfeo_unpack_, flag, :mat) + blasfeo_pack = Symbol(:blasfeo_pack_, flag, :mat) + @eval function Base.convert(::Type{Matrix{eltype($type)}}, A::$type) + A_ptr = pointer_from_objref(A) + B = Matrix{eltype($type)}(undef, size(A)) + @ccall blasfeo.$blasfeo_unpack( + A.m::Cint, A.n::Cint, + A_ptr::Ptr{$type}, + 0::Cint, 0::Cint, + B::Ptr{eltype($type)}, + A.m::Cint + )::Cvoid + return B + end + @eval function Base.convert(::Type{$type}, A::Matrix{eltype($type)}) + B = $type(size(A)...) + B_ptr = pointer_from_objref(B) + m,n = size(A) + @ccall blasfeo.$blasfeo_pack( + m::Cint, n::Cint, + A::Ptr{eltype($type)}, m::Cint, + B_ptr::Ptr{$type}, + 0::Cint, 0::Cint + )::Cvoid + return B end end diff --git a/src/vecs.jl b/src/vecs.jl index 7384649..509809e 100644 --- a/src/vecs.jl +++ b/src/vecs.jl @@ -91,11 +91,11 @@ for (type,flag) in [ # copy blasfeo_veccp = Symbol(:blasfeo_, flag, :veccp) - @eval function copy(A::$type) + @eval function Base.copy(A::$type) B = similar(A) A_ptr = pointer_from_objref(A) B_ptr = pointer_from_objref(B) - @ccall blasfeo.blasfeo_veccp( + @ccall blasfeo.$blasfeo_veccp( A.m::Cint, A_ptr::Ptr{$type}, 0::Cint, B_ptr::Ptr{$type}, 0::Cint, @@ -103,14 +103,15 @@ for (type,flag) in [ return B end - # fill + # fill! blasfeo_vecse = Symbol(:blasfeo_, flag, :vecse) - @eval function fill(A::$type, b::T) where {T <: Real} + @eval function Base.fill!(A::$type, b::T) where {T <: Real} A_ptr = pointer_from_objref(A) - @ccall blasfeo.blasfeo_vecse( + @ccall blasfeo.$blasfeo_vecse( A.m::Cint, b::eltype($type), A_ptr::Ptr{$type}, 0::Cint, )::Cvoid + return A end end From 732bb85cb1ed6b0653e68cb84cf497b0a744e9eb Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 10:57:30 +0200 Subject: [PATCH 05/20] move to Clang.jl generated low level wrapper --- Project.toml | 2 + generator.jl | 33 + generator.toml | 11 + src/BLASFEO.jl | 5 +- src/lib/LibBlasfeo.jl | 3611 +++++++++++++++++++++++++++++++++++++++++ src/mats.jl | 110 +- src/show.jl | 38 +- 7 files changed, 3728 insertions(+), 82 deletions(-) create mode 100644 generator.jl create mode 100644 generator.toml create mode 100644 src/lib/LibBlasfeo.jl diff --git a/Project.toml b/Project.toml index 01e1db6..83d8561 100644 --- a/Project.toml +++ b/Project.toml @@ -4,10 +4,12 @@ version = "0.1.0" authors = ["Ian McInerney", "Imperial College London"] [deps] +CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" blasfeo_jll = "6b574d4a-bb57-5a4b-b7e6-1c794c903646" [compat] +CEnum = "0.5.0" LinearAlgebra = "1.12.0" julia = "1" diff --git a/generator.jl b/generator.jl new file mode 100644 index 0000000..ad2ebd1 --- /dev/null +++ b/generator.jl @@ -0,0 +1,33 @@ +using Clang.Generators +using blasfeo_jll + +cd(@__DIR__) + +include_dir = normpath(blasfeo_jll.artifact_dir, "blasfeo/include") + +# wrapper generator options +options = load_options(joinpath(@__DIR__, "generator.toml")) + +# add compiler flags +args = get_default_args() +#push!(args, "-I$include_dir") +push!(args, "-DMF_PANELMAJ") +push!(args, "-DLA_HIGH_PERFORMANCE") +push!(args, "-DEXT_DEP_MALLOC") +push!(args, "-DEXT_DEP") +push!(args, "-fparse-all-comments") # Parse all comments! + +# Only include headers defining the blasfeo API +# TODO(@anton) it may be useful to expose the kernels in the future, per conversation with @perrutquist. +headers = [ + joinpath(include_dir, "blasfeo_d_blasfeo_api.h"), joinpath(include_dir, "blasfeo_s_blasfeo_api.h"), + joinpath(include_dir, "blasfeo_d_aux.h"), joinpath(include_dir, "blasfeo_s_aux.h"), + joinpath(include_dir, "blasfeo_d_aux_ext_dep.h"), joinpath(include_dir, "blasfeo_s_aux_ext_dep.h"), + +] + +# create context +ctx = create_context(headers, args, options) + +# run generator +build!(ctx) diff --git a/generator.toml b/generator.toml new file mode 100644 index 0000000..6f4d868 --- /dev/null +++ b/generator.toml @@ -0,0 +1,11 @@ +[general] +library_name = "blasfeo" +output_file_path = "./src/lib/LibBlasfeo.jl" +module_name = "LibBlasfeo" +jll_pkg_name = "blasfeo_jll" +export_symbol_prefixes = ["blasfeo_"] +extract_c_comment_style = "raw" +auto_mutability = true +[codegen] +is_function_strictly_typed = false +use_ccall_macro = true \ No newline at end of file diff --git a/src/BLASFEO.jl b/src/BLASFEO.jl index d32c6ed..85d3c7f 100644 --- a/src/BLASFEO.jl +++ b/src/BLASFEO.jl @@ -1,6 +1,9 @@ module BLASFEO using LinearAlgebra -using blasfeo_jll + +include("lib/LibBlasfeo.jl") +using .LibBlasfeo + include("vecs.jl") include("mats.jl") include("show.jl") diff --git a/src/lib/LibBlasfeo.jl b/src/lib/LibBlasfeo.jl new file mode 100644 index 0000000..cbc4bcc --- /dev/null +++ b/src/lib/LibBlasfeo.jl @@ -0,0 +1,3611 @@ +module LibBlasfeo + +using blasfeo_jll +export blasfeo_jll + +using CEnum: CEnum, @cenum + +""" + blasfeo_dmat + +matrix structure +""" +struct blasfeo_dmat + mem::Ptr{Cdouble} + pA::Ptr{Cdouble} + dA::Ptr{Cdouble} + m::Cint + n::Cint + pm::Cint + cn::Cint + use_dA::Cint + memsize::Cint +end + +struct blasfeo_smat + mem::Ptr{Cfloat} + pA::Ptr{Cfloat} + dA::Ptr{Cfloat} + m::Cint + n::Cint + pm::Cint + cn::Cint + use_dA::Cint + memsize::Cint +end + +""" + blasfeo_dvec + +vector structure +""" +struct blasfeo_dvec + mem::Ptr{Cdouble} + pa::Ptr{Cdouble} + m::Cint + pm::Cint + memsize::Cint +end + +struct blasfeo_svec + mem::Ptr{Cfloat} + pa::Ptr{Cfloat} + m::Cint + pm::Cint + memsize::Cint +end + +""" + blasfeo_pm_dmat + +Explicitly panel-major matrix structure +""" +struct blasfeo_pm_dmat + mem::Ptr{Cdouble} + pA::Ptr{Cdouble} + dA::Ptr{Cdouble} + m::Cint + n::Cint + pm::Cint + cn::Cint + use_dA::Cint + ps::Cint + memsize::Cint +end + +struct blasfeo_pm_smat + mem::Ptr{Cfloat} + pA::Ptr{Cfloat} + dA::Ptr{Cfloat} + m::Cint + n::Cint + pm::Cint + cn::Cint + use_dA::Cint + ps::Cint + memsize::Cint +end + +mutable struct blasfeo_pm_dvec + mem::Ptr{Cdouble} + pa::Ptr{Cdouble} + m::Cint + pm::Cint + memsize::Cint + blasfeo_pm_dvec() = new() +end + +mutable struct blasfeo_pm_svec + mem::Ptr{Cfloat} + pa::Ptr{Cfloat} + m::Cint + pm::Cint + memsize::Cint + blasfeo_pm_svec() = new() +end + +""" + blasfeo_cm_dmat + +Explicitly column-major matrix structure +""" +mutable struct blasfeo_cm_dmat + mem::Ptr{Cdouble} + pA::Ptr{Cdouble} + dA::Ptr{Cdouble} + m::Cint + n::Cint + use_dA::Cint + memsize::Cint + blasfeo_cm_dmat() = new() +end + +mutable struct blasfeo_cm_smat + mem::Ptr{Cfloat} + pA::Ptr{Cfloat} + dA::Ptr{Cfloat} + m::Cint + n::Cint + use_dA::Cint + memsize::Cint + blasfeo_cm_smat() = new() +end + +mutable struct blasfeo_cm_dvec + mem::Ptr{Cdouble} + pa::Ptr{Cdouble} + m::Cint + memsize::Cint + blasfeo_cm_dvec() = new() +end + +mutable struct blasfeo_cm_svec + mem::Ptr{Cfloat} + pa::Ptr{Cfloat} + m::Cint + memsize::Cint + blasfeo_cm_svec() = new() +end + +""" + blasfeo_daxpy(kmax, alpha, sx, xi, sy, yi, sz, zi) + +z = y + alpha*x +z[zi:zi+n] = alpha*x[xi:xi+n] + y[yi:yi+n] +NB: Different arguments semantic compare to equivalent standard BLAS routine +""" +function blasfeo_daxpy(kmax, alpha, sx, xi, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_daxpy(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_daxpby(kmax, alpha, sx, xi, beta, sy, yi, sz, zi) + +z = beta*y + alpha*x +""" +function blasfeo_daxpby(kmax, alpha, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_daxpby(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, beta::Cdouble, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dvecmul(m, sx, xi, sy, yi, sz, zi) + +z = x .* y +""" +function blasfeo_dvecmul(m, sx, xi, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_dvecmul(m::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dvecmulacc(m, sx, xi, sy, yi, sz, zi) + +z += x .* y +""" +function blasfeo_dvecmulacc(m, sx, xi, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_dvecmulacc(m::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dvecmuldot(m, sx, xi, sy, yi, sz, zi) + +z = x .* y, return sum(z) = x^T * y +""" +function blasfeo_dvecmuldot(m, sx, xi, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_dvecmuldot(m::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cdouble +end + +""" + blasfeo_ddot(m, sx, xi, sy, yi) + +return x^T * y +""" +function blasfeo_ddot(m, sx, xi, sy, yi) + @ccall blasfeo.blasfeo_ddot(m::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint)::Cdouble +end + +""" + blasfeo_drotg(a, b, c, s) + +construct givens plane rotation +""" +function blasfeo_drotg(a, b, c, s) + @ccall blasfeo.blasfeo_drotg(a::Cdouble, b::Cdouble, c::Ptr{Cdouble}, s::Ptr{Cdouble})::Cvoid +end + +""" + blasfeo_dcolrot(m, sA, ai, aj0, aj1, c, s) + +apply plane rotation [a b] [c -s; s; c] to the aj0 and aj1 columns of A at row index ai +""" +function blasfeo_dcolrot(m, sA, ai, aj0, aj1, c, s) + @ccall blasfeo.blasfeo_dcolrot(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj0::Cint, aj1::Cint, c::Cdouble, s::Cdouble)::Cvoid +end + +""" + blasfeo_drowrot(m, sA, ai0, ai1, aj, c, s) + +apply plane rotation [c s; -s c] [a; b] to the ai0 and ai1 rows of A at column index aj +""" +function blasfeo_drowrot(m, sA, ai0, ai1, aj, c, s) + @ccall blasfeo.blasfeo_drowrot(m::Cint, sA::Ptr{blasfeo_dmat}, ai0::Cint, ai1::Cint, aj::Cint, c::Cdouble, s::Cdouble)::Cvoid +end + +""" + blasfeo_dgemv_n(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A * x +""" +function blasfeo_dgemv_n(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_dgemv_n(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, beta::Cdouble, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dgemv_t(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A^T * x +""" +function blasfeo_dgemv_t(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_dgemv_t(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, beta::Cdouble, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrsv_lnn_mn(m, n, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A ) * x, A (m)x(n) +""" +function blasfeo_dtrsv_lnn_mn(m, n, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrsv_lnn_mn(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrsv_ltn_mn(m, n, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A^T ) * x, A (m)x(n) +""" +function blasfeo_dtrsv_ltn_mn(m, n, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrsv_ltn_mn(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrsv_lnn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A ) * x, A (m)x(m) lower, not_transposed +""" +function blasfeo_dtrsv_lnn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrsv_lnn(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrsv_lnu(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A ) * x, A (m)x(m) lower, not_transposed, assuming unit diagonal +""" +function blasfeo_dtrsv_lnu(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrsv_lnu(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrsv_ltn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A^T ) * x, A (m)x(m) lower, transposed +""" +function blasfeo_dtrsv_ltn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrsv_ltn(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrsv_ltu(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A^T ) * x, A (m)x(m) lower, transposed, assuming unit diagonal +""" +function blasfeo_dtrsv_ltu(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrsv_ltu(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrsv_unn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A^T ) * x, A (m)x(m) upper, not_transposed +""" +function blasfeo_dtrsv_unn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrsv_unn(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrsv_utn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A^T ) * x, A (m)x(m) upper, transposed +""" +function blasfeo_dtrsv_utn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrsv_utn(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrmv_lnn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A * x ; A lower triangular +""" +function blasfeo_dtrmv_lnn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrmv_lnn(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrmv_lnu(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A * x ; A lower triangular, assuming unit diagonal +""" +function blasfeo_dtrmv_lnu(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrmv_lnu(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrmv_ltn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A^T * x ; A lower triangular +""" +function blasfeo_dtrmv_ltn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrmv_ltn(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrmv_ltu(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A^T * x ; A lower triangular, assuming unit diagonal +""" +function blasfeo_dtrmv_ltu(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrmv_ltu(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrmv_unn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= beta * y + alpha * A * x ; A upper triangular +""" +function blasfeo_dtrmv_unn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrmv_unn(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dtrmv_utn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A^T * x ; A upper triangular +""" +function blasfeo_dtrmv_utn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dtrmv_utn(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dgemv_nt(m, n, alpha_n, alpha_t, sA, ai, aj, sx_n, xi_n, sx_t, xi_t, beta_n, beta_t, sy_n, yi_n, sy_t, yi_t, sz_n, zi_n, sz_t, zi_t) + +z_n <= beta_n * y_n + alpha_n * A * x_n +z_t <= beta_t * y_t + alpha_t * A^T * x_t +""" +function blasfeo_dgemv_nt(m, n, alpha_n, alpha_t, sA, ai, aj, sx_n, xi_n, sx_t, xi_t, beta_n, beta_t, sy_n, yi_n, sy_t, yi_t, sz_n, zi_n, sz_t, zi_t) + @ccall blasfeo.blasfeo_dgemv_nt(m::Cint, n::Cint, alpha_n::Cdouble, alpha_t::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx_n::Ptr{blasfeo_dvec}, xi_n::Cint, sx_t::Ptr{blasfeo_dvec}, xi_t::Cint, beta_n::Cdouble, beta_t::Cdouble, sy_n::Ptr{blasfeo_dvec}, yi_n::Cint, sy_t::Ptr{blasfeo_dvec}, yi_t::Cint, sz_n::Ptr{blasfeo_dvec}, zi_n::Cint, sz_t::Ptr{blasfeo_dvec}, zi_t::Cint)::Cvoid +end + +""" + blasfeo_dsymv_l(m, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A * x, where A is symmetric and only the lower triangular patr of A is accessed +""" +function blasfeo_dsymv_l(m, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_dsymv_l(m::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, beta::Cdouble, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +function blasfeo_dsymv_l_mn(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_dsymv_l_mn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, beta::Cdouble, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dsymv_u(m, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A * x, where A is symmetric and only the upper triangular patr of A is accessed +""" +function blasfeo_dsymv_u(m, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_dsymv_u(m::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, beta::Cdouble, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dger(m, n, alpha, sx, xi, sy, yi, sC, ci, cj, sD, di, dj) + +D = C + alpha * x * y^T +""" +function blasfeo_dger(m, n, alpha, sx, xi, sy, yi, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dger(m::Cint, n::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dgemv_d(m, alpha, sA, ai, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A * x, A diagonal +""" +function blasfeo_dgemv_d(m, alpha, sA, ai, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_dgemv_d(m::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dvec}, ai::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, beta::Cdouble, sy::Ptr{blasfeo_dvec}, yi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dgemm_nn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B +""" +function blasfeo_dgemm_nn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dgemm_nn(m::Cint, n::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dgemm_nt(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T +""" +function blasfeo_dgemm_nt(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dgemm_nt(m::Cint, n::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dgemm_tn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B +""" +function blasfeo_dgemm_tn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dgemm_tn(m::Cint, n::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dgemm_tt(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B^T +""" +function blasfeo_dgemm_tt(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dgemm_tt(m::Cint, n::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dsyrk_ln(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T ; C, D lower triangular +""" +function blasfeo_dsyrk_ln(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyrk_ln(m::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_dsyrk_ln_mn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyrk_ln_mn(m::Cint, n::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dsyrk_lt(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B ; C, D lower triangular +""" +function blasfeo_dsyrk_lt(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyrk_lt(m::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dsyrk_un(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T ; C, D upper triangular +""" +function blasfeo_dsyrk_un(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyrk_un(m::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dsyrk_ut(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B ; C, D upper triangular +""" +function blasfeo_dsyrk_ut(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyrk_ut(m::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_llnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A * B ; A lower triangular +""" +function blasfeo_dtrmm_llnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_llnn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_llnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A * B ; A lower triangular assuming unit diagonal +""" +function blasfeo_dtrmm_llnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_llnu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_lltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^T * B ; A lower triangular +""" +function blasfeo_dtrmm_lltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_lltn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_lltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^T * B ; A lower triangular assuming unit diagonal +""" +function blasfeo_dtrmm_lltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_lltu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_lunn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A * B ; A upper triangular +""" +function blasfeo_dtrmm_lunn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_lunn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_lunu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A * B ; A upper triangular assuming unit diagonal +""" +function blasfeo_dtrmm_lunu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_lunu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_lutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^T * B ; A upper triangular +""" +function blasfeo_dtrmm_lutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_lutn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_lutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^T * B ; A upper triangular assuming unit diagonal +""" +function blasfeo_dtrmm_lutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_lutu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_rlnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A ; A lower triangular +""" +function blasfeo_dtrmm_rlnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_rlnn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_rlnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A ; A lower triangular assuming unit diagonal +""" +function blasfeo_dtrmm_rlnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_rlnu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_rltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^T ; A lower triangular +""" +function blasfeo_dtrmm_rltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_rltn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_rltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^T ; A lower triangular assuming unit diagonal +""" +function blasfeo_dtrmm_rltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_rltu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_runn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A ; A upper triangular +""" +function blasfeo_dtrmm_runn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_runn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_runu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A ; A upper triangular assuming unit diagonal +""" +function blasfeo_dtrmm_runu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_runu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_rutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^T ; A upper triangular +""" +function blasfeo_dtrmm_rutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_rutn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrmm_rutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^T ; A upper triangular assuming unit diagonal +""" +function blasfeo_dtrmm_rutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrmm_rutu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_llnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-1} * B , with A lower triangular employing explicit inverse of diagonal +""" +function blasfeo_dtrsm_llnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_llnn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_llnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-1} * B , with A lower triangular assuming unit diagonal +""" +function blasfeo_dtrsm_llnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_llnu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_lltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-T} * B , with A lower triangular employing explicit inverse of diagonal +""" +function blasfeo_dtrsm_lltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_lltn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_lltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-T} * B , with A lower triangular assuming unit diagonal +""" +function blasfeo_dtrsm_lltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_lltu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_lunn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-1} * B , with A upper triangular employing explicit inverse of diagonal +""" +function blasfeo_dtrsm_lunn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_lunn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_lunu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-1} * B , with A upper triangular assuming unit diagonal +""" +function blasfeo_dtrsm_lunu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_lunu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_lutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-T} * B , with A upper triangular employing explicit inverse of diagonal +""" +function blasfeo_dtrsm_lutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_lutn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_lutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-T} * B , with A upper triangular assuming unit diagonal +""" +function blasfeo_dtrsm_lutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_lutu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_rlnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-1} , with A lower triangular employing explicit inverse of diagonal +""" +function blasfeo_dtrsm_rlnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_rlnn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_rlnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-1} , with A lower triangular assuming unit diagonal +""" +function blasfeo_dtrsm_rlnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_rlnu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_rltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-T} , with A lower triangular employing explicit inverse of diagonal +""" +function blasfeo_dtrsm_rltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_rltn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_rltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-T} , with A lower triangular assuming unit diagonal +""" +function blasfeo_dtrsm_rltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_rltu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_runn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-1} , with A upper triangular employing explicit inverse of diagonal +""" +function blasfeo_dtrsm_runn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_runn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_runu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-1} , with A upper triangular assuming unit diagonal +""" +function blasfeo_dtrsm_runu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_runu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_rutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-T} , with A upper triangular employing explicit inverse of diagonal +""" +function blasfeo_dtrsm_rutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_rutn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dtrsm_rutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-T} , with A upper triangular assuming unit diagonal +""" +function blasfeo_dtrsm_rutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_dtrsm_rutu(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dsyr2k_ln(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T + alpha * B * A^T; C, D lower triangular +""" +function blasfeo_dsyr2k_ln(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyr2k_ln(m::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dsyr2k_lt(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B + alpha * B^T * A; C, D lower triangular +""" +function blasfeo_dsyr2k_lt(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyr2k_lt(m::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dsyr2k_un(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T + alpha * B * A^T; C, D upper triangular +""" +function blasfeo_dsyr2k_un(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyr2k_un(m::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dsyr2k_ut(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B + alpha * B^T * A; C, D upper triangular +""" +function blasfeo_dsyr2k_ut(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyr2k_ut(m::Cint, k::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + dgemm_diag_left_lib(m, n, alpha, dA, pB, sdb, beta, pC, sdc, pD, sdd) + +D <= alpha * A * B + beta * C, with A diagonal (stored as strvec) +""" +function dgemm_diag_left_lib(m, n, alpha, dA, pB, sdb, beta, pC, sdc, pD, sdd) + @ccall blasfeo.dgemm_diag_left_lib(m::Cint, n::Cint, alpha::Cdouble, dA::Ptr{Cdouble}, pB::Ptr{Cdouble}, sdb::Cint, beta::Cdouble, pC::Ptr{Cdouble}, sdc::Cint, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function blasfeo_dgemm_dn(m, n, alpha, sA, ai, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dgemm_dn(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dvec}, ai::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dgemm_nd(m, n, alpha, sA, ai, aj, sB, bi, beta, sC, ci, cj, sD, di, dj) + +D <= alpha * A * B + beta * C, with B diagonal (stored as strvec) +""" +function blasfeo_dgemm_nd(m, n, alpha, sA, ai, aj, sB, bi, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dgemm_nd(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dvec}, bi::Cint, beta::Cdouble, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dpotrf_l(m, sC, ci, cj, sD, di, dj) + +D <= chol( C ) ; C, D lower triangular +""" +function blasfeo_dpotrf_l(m, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dpotrf_l(m::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_dpotrf_l_mn(m, n, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dpotrf_l_mn(m::Cint, n::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dpotrf_u(m, sC, ci, cj, sD, di, dj) + +D <= chol( C ) ; C, D upper triangular +""" +function blasfeo_dpotrf_u(m, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dpotrf_u(m::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dsyrk_dpotrf_ln(m, k, sA, ai, aj, sB, bi, bj, sC, ci, cj, sD, di, dj) + +D <= chol( C + A * B' ) ; C, D lower triangular +D <= chol( C + A * B^T ) ; C, D lower triangular +""" +function blasfeo_dsyrk_dpotrf_ln(m, k, sA, ai, aj, sB, bi, bj, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyrk_dpotrf_ln(m::Cint, k::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_dsyrk_dpotrf_ln_mn(m, n, k, sA, ai, aj, sB, bi, bj, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dsyrk_dpotrf_ln_mn(m::Cint, n::Cint, k::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dgetrf_np(m, n, sC, ci, cj, sD, di, dj) + +D <= lu( C ) ; no pivoting +""" +function blasfeo_dgetrf_np(m, n, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_dgetrf_np(m::Cint, n::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_dgetrf_rp(m, n, sC, ci, cj, sD, di, dj, ipiv) + +D <= lu( C ) ; row pivoting +""" +function blasfeo_dgetrf_rp(m, n, sC, ci, cj, sD, di, dj, ipiv) + @ccall blasfeo.blasfeo_dgetrf_rp(m::Cint, n::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint, ipiv::Ptr{Cint})::Cvoid +end + +""" + blasfeo_dgeqrf_worksize(m, n) + +D <= qr( C ) +""" +function blasfeo_dgeqrf_worksize(m, n) + @ccall blasfeo.blasfeo_dgeqrf_worksize(m::Cint, n::Cint)::Cint +end + +function blasfeo_dgeqrf(m, n, sC, ci, cj, sD, di, dj, work) + @ccall blasfeo.blasfeo_dgeqrf(m::Cint, n::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint, work::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_dorglq_worksize(m, n, k) + +D <= Q factor, where C is the output of the LQ factorization +""" +function blasfeo_dorglq_worksize(m, n, k) + @ccall blasfeo.blasfeo_dorglq_worksize(m::Cint, n::Cint, k::Cint)::Cint +end + +function blasfeo_dorglq(m, n, k, sC, ci, cj, sD, di, dj, work) + @ccall blasfeo.blasfeo_dorglq(m::Cint, n::Cint, k::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint, work::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_dgelqf(m, n, sC, ci, cj, sD, di, dj, work) + +D <= lq( C ) +""" +function blasfeo_dgelqf(m, n, sC, ci, cj, sD, di, dj, work) + @ccall blasfeo.blasfeo_dgelqf(m::Cint, n::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint, work::Ptr{Cvoid})::Cvoid +end + +function blasfeo_dgelqf_worksize(m, n) + @ccall blasfeo.blasfeo_dgelqf_worksize(m::Cint, n::Cint)::Cint +end + +""" + blasfeo_dgelqf_pd(m, n, sC, ci, cj, sD, di, dj, work) + +D <= lq( C ), positive diagonal elements +""" +function blasfeo_dgelqf_pd(m, n, sC, ci, cj, sD, di, dj, work) + @ccall blasfeo.blasfeo_dgelqf_pd(m::Cint, n::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint, work::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_dgelqf_pd_la(m, n1, sL, li, lj, sA, ai, aj, work) + +[L, A] <= lq( [L, A] ), positive diagonal elements, array of matrices, with +L lower triangular, of size (m)x(m) +A full, of size (m)x(n1) +""" +function blasfeo_dgelqf_pd_la(m, n1, sL, li, lj, sA, ai, aj, work) + @ccall blasfeo.blasfeo_dgelqf_pd_la(m::Cint, n1::Cint, sL::Ptr{blasfeo_dmat}, li::Cint, lj::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, work::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_dgelqf_pd_lla(m, n1, sL0, l0i, l0j, sL1, l1i, l1j, sA, ai, aj, work) + +[L, L, A] <= lq( [L, L, A] ), positive diagonal elements, array of matrices, with: +L lower triangular, of size (m)x(m) +A full, of size (m)x(n1) +""" +function blasfeo_dgelqf_pd_lla(m, n1, sL0, l0i, l0j, sL1, l1i, l1j, sA, ai, aj, work) + @ccall blasfeo.blasfeo_dgelqf_pd_lla(m::Cint, n1::Cint, sL0::Ptr{blasfeo_dmat}, l0i::Cint, l0j::Cint, sL1::Ptr{blasfeo_dmat}, l1i::Cint, l1j::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, work::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_saxpy(kmax, alpha, sx, xi, sy, yi, sz, zi) + +z = y + alpha*x +""" +function blasfeo_saxpy(kmax, alpha, sx, xi, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_saxpy(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_saxpby(kmax, alpha, sx, xi, beta, sy, yi, sz, zi) + +z = beta*y + alpha*x +""" +function blasfeo_saxpby(kmax, alpha, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_saxpby(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, beta::Cfloat, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_svecmul(m, sx, xi, sy, yi, sz, zi) + +z = x .* y +""" +function blasfeo_svecmul(m, sx, xi, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_svecmul(m::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_svecmulacc(m, sx, xi, sy, yi, sz, zi) + +z += x .* y +""" +function blasfeo_svecmulacc(m, sx, xi, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_svecmulacc(m::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_svecmuldot(m, sx, xi, sy, yi, sz, zi) + +z = x .* y, return sum(z) = x^T * y +""" +function blasfeo_svecmuldot(m, sx, xi, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_svecmuldot(m::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cfloat +end + +""" + blasfeo_sdot(m, sx, xi, sy, yi) + +return x^T * y +""" +function blasfeo_sdot(m, sx, xi, sy, yi) + @ccall blasfeo.blasfeo_sdot(m::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sy::Ptr{blasfeo_svec}, yi::Cint)::Cfloat +end + +""" + blasfeo_srotg(a, b, c, s) + +construct givens plane rotation +""" +function blasfeo_srotg(a, b, c, s) + @ccall blasfeo.blasfeo_srotg(a::Cfloat, b::Cfloat, c::Ptr{Cfloat}, s::Ptr{Cfloat})::Cvoid +end + +""" + blasfeo_scolrot(m, sA, ai, aj0, aj1, c, s) + +apply plane rotation [a b] [c -s; s; c] to the aj0 and aj1 columns of A at row index ai +""" +function blasfeo_scolrot(m, sA, ai, aj0, aj1, c, s) + @ccall blasfeo.blasfeo_scolrot(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj0::Cint, aj1::Cint, c::Cfloat, s::Cfloat)::Cvoid +end + +""" + blasfeo_srowrot(m, sA, ai0, ai1, aj, c, s) + +apply plane rotation [c s; -s c] [a; b] to the ai0 and ai1 rows of A at column index aj +""" +function blasfeo_srowrot(m, sA, ai0, ai1, aj, c, s) + @ccall blasfeo.blasfeo_srowrot(m::Cint, sA::Ptr{blasfeo_smat}, ai0::Cint, ai1::Cint, aj::Cint, c::Cfloat, s::Cfloat)::Cvoid +end + +""" + blasfeo_sgemv_n(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A * x +""" +function blasfeo_sgemv_n(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_sgemv_n(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, beta::Cfloat, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_sgemv_t(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A' * x +""" +function blasfeo_sgemv_t(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_sgemv_t(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, beta::Cfloat, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strsv_lnn_mn(m, n, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A ) * x, A (m)x(n) +""" +function blasfeo_strsv_lnn_mn(m, n, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strsv_lnn_mn(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strsv_ltn_mn(m, n, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A' ) * x, A (m)x(n) +""" +function blasfeo_strsv_ltn_mn(m, n, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strsv_ltn_mn(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strsv_lnn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A ) * x, A (m)x(m) lower, not_transposed +""" +function blasfeo_strsv_lnn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strsv_lnn(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strsv_lnu(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A ) * x, A (m)x(m) lower, not_transposed, assuming unit diagonal +""" +function blasfeo_strsv_lnu(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strsv_lnu(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strsv_ltn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A' ) * x, A (m)x(m) lower, transposed +""" +function blasfeo_strsv_ltn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strsv_ltn(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strsv_ltu(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A' ) * x, A (m)x(m) lower, transposed, assuming unit diagonal +""" +function blasfeo_strsv_ltu(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strsv_ltu(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strsv_unn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A' ) * x, A (m)x(m) upper, not_transposed +""" +function blasfeo_strsv_unn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strsv_unn(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strsv_utn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= inv( A' ) * x, A (m)x(m) upper, transposed +""" +function blasfeo_strsv_utn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strsv_utn(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strmv_lnn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A * x ; A lower triangular +""" +function blasfeo_strmv_lnn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strmv_lnn(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strmv_lnu(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A * x ; A lower triangular, assuming unit diagonal +""" +function blasfeo_strmv_lnu(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strmv_lnu(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strmv_ltn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A' * x ; A lower triangular +""" +function blasfeo_strmv_ltn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strmv_ltn(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strmv_ltu(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A' * x ; A lower triangular, assuming unit diagonal +""" +function blasfeo_strmv_ltu(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strmv_ltu(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strmv_unn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= beta * y + alpha * A * x ; A upper triangular +""" +function blasfeo_strmv_unn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strmv_unn(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_strmv_utn(m, sA, ai, aj, sx, xi, sz, zi) + +z <= A' * x ; A upper triangular +""" +function blasfeo_strmv_utn(m, sA, ai, aj, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_strmv_utn(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_sgemv_nt(m, n, alpha_n, alpha_t, sA, ai, aj, sx_n, xi_n, sx_t, xi_t, beta_n, beta_t, sy_n, yi_n, sy_t, yi_t, sz_n, zi_n, sz_t, zi_t) + +z_n <= beta_n * y_n + alpha_n * A * x_n +z_t <= beta_t * y_t + alpha_t * A' * x_t +""" +function blasfeo_sgemv_nt(m, n, alpha_n, alpha_t, sA, ai, aj, sx_n, xi_n, sx_t, xi_t, beta_n, beta_t, sy_n, yi_n, sy_t, yi_t, sz_n, zi_n, sz_t, zi_t) + @ccall blasfeo.blasfeo_sgemv_nt(m::Cint, n::Cint, alpha_n::Cfloat, alpha_t::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx_n::Ptr{blasfeo_svec}, xi_n::Cint, sx_t::Ptr{blasfeo_svec}, xi_t::Cint, beta_n::Cfloat, beta_t::Cfloat, sy_n::Ptr{blasfeo_svec}, yi_n::Cint, sy_t::Ptr{blasfeo_svec}, yi_t::Cint, sz_n::Ptr{blasfeo_svec}, zi_n::Cint, sz_t::Ptr{blasfeo_svec}, zi_t::Cint)::Cvoid +end + +""" + blasfeo_ssymv_l(m, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A * x, where A is symmetric and only the lower triangular patr of A is accessed +""" +function blasfeo_ssymv_l(m, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_ssymv_l(m::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, beta::Cfloat, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +function blasfeo_ssymv_l_mn(m, n, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_ssymv_l_mn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, beta::Cfloat, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_ssymv_u(m, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A * x, where A is symmetric and only the upper triangular patr of A is accessed +""" +function blasfeo_ssymv_u(m, alpha, sA, ai, aj, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_ssymv_u(m::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, beta::Cfloat, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_sger(m, n, alpha, sx, xi, sy, yi, sC, ci, cj, sD, di, dj) + +D = C + alpha * x * y^T +""" +function blasfeo_sger(m, n, alpha, sx, xi, sy, yi, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_sger(m::Cint, n::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, sy::Ptr{blasfeo_svec}, yi::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_sgemv_d(m, alpha, sA, ai, sx, xi, beta, sy, yi, sz, zi) + +z <= beta * y + alpha * A * x, A diagonal +""" +function blasfeo_sgemv_d(m, alpha, sA, ai, sx, xi, beta, sy, yi, sz, zi) + @ccall blasfeo.blasfeo_sgemv_d(m::Cint, alpha::Cfloat, sA::Ptr{blasfeo_svec}, ai::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, beta::Cfloat, sy::Ptr{blasfeo_svec}, yi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_sgemm_nn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B +""" +function blasfeo_sgemm_nn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_sgemm_nn(m::Cint, n::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_sgemm_nt(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T +""" +function blasfeo_sgemm_nt(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_sgemm_nt(m::Cint, n::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_sgemm_tn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B +""" +function blasfeo_sgemm_tn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_sgemm_tn(m::Cint, n::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_sgemm_tt(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B +""" +function blasfeo_sgemm_tt(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_sgemm_tt(m::Cint, n::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ssyrk_ln(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T ; C, D lower triangular +""" +function blasfeo_ssyrk_ln(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyrk_ln(m::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_ssyrk_ln_mn(m, n, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyrk_ln_mn(m::Cint, n::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ssyrk_lt(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B ; C, D lower triangular +""" +function blasfeo_ssyrk_lt(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyrk_lt(m::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ssyrk_un(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T ; C, D upper triangular +""" +function blasfeo_ssyrk_un(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyrk_un(m::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ssyrk_ut(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B ; C, D upper triangular +""" +function blasfeo_ssyrk_ut(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyrk_ut(m::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_llnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A * B ; A lower triangular +""" +function blasfeo_strmm_llnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_llnn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_llnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A * B ; A lower triangular assuming unit diagonal +""" +function blasfeo_strmm_llnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_llnu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_lltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^T * B ; A lower triangular +""" +function blasfeo_strmm_lltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_lltn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_lltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^T * B ; A lower triangular assuming unit diagonal +""" +function blasfeo_strmm_lltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_lltu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_lunn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A * B ; A upper triangular +""" +function blasfeo_strmm_lunn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_lunn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_lunu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A * B ; A upper triangular assuming unit diagonal +""" +function blasfeo_strmm_lunu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_lunu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_lutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^T * B ; A upper triangular +""" +function blasfeo_strmm_lutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_lutn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_lutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^T * B ; A upper triangular assuming unit diagonal +""" +function blasfeo_strmm_lutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_lutu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_rlnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A ; A lower triangular +""" +function blasfeo_strmm_rlnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_rlnn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_rlnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A ; A lower triangular assuming unit diagonal +""" +function blasfeo_strmm_rlnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_rlnu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_rltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^T ; A lower triangular +""" +function blasfeo_strmm_rltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_rltn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_rltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^T ; A lower triangular assuming unit diagonal +""" +function blasfeo_strmm_rltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_rltu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_runn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A ; A upper triangular +""" +function blasfeo_strmm_runn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_runn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_runu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A ; A upper triangular assuming unit diagonal +""" +function blasfeo_strmm_runu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_runu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_rutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^T ; A upper triangular +""" +function blasfeo_strmm_rutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_rutn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strmm_rutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^T ; A upper triangular assuming unit diagonal +""" +function blasfeo_strmm_rutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strmm_rutu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_llnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-1} * B , with A lower triangular employint explicit inverse of diagonal +""" +function blasfeo_strsm_llnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_llnn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_llnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-1} * B , with A lower triangular assuming unit diagonal +""" +function blasfeo_strsm_llnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_llnu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_lltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-T} * B , with A lower triangular employint explicit inverse of diagonal +""" +function blasfeo_strsm_lltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_lltn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_lltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-T} * B , with A lower triangular assuming unit diagonal +""" +function blasfeo_strsm_lltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_lltu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_lunn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-1} * B , with A upper triangular employing explicit inverse of diagonal +""" +function blasfeo_strsm_lunn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_lunn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_lunu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-1} * B , with A upper triangular assuming unit diagonal +""" +function blasfeo_strsm_lunu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_lunu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_lutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-T} * B , with A upper triangular employing explicit inverse of diagonal +""" +function blasfeo_strsm_lutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_lutn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_lutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * A^{-T} * B , with A upper triangular assuming unit diagonal +""" +function blasfeo_strsm_lutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_lutu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_rlnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-1} , with A lower triangular employing explicit inverse of diagonal +""" +function blasfeo_strsm_rlnn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_rlnn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_rlnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-1} , with A lower triangular assuming unit diagonal +""" +function blasfeo_strsm_rlnu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_rlnu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_rltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-T} , with A lower triangular employing explicit inverse of diagonal +""" +function blasfeo_strsm_rltn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_rltn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_rltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-T} , with A lower triangular assuming unit diagonal +""" +function blasfeo_strsm_rltu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_rltu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_runn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-1} , with A upper triangular employing explicit inverse of diagonal +""" +function blasfeo_strsm_runn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_runn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_runu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-1} , with A upper triangular assuming unit diagonal +""" +function blasfeo_strsm_runu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_runu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_rutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-T} , with A upper triangular employing explicit inverse of diagonal +""" +function blasfeo_strsm_rutn(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_rutn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_strsm_rutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + +D <= alpha * B * A^{-T} , with A upper triangular assuming unit diagonal +""" +function blasfeo_strsm_rutu(m, n, alpha, sA, ai, aj, sB, bi, bj, sD, di, dj) + @ccall blasfeo.blasfeo_strsm_rutu(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ssyr2k_ln(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T + alpha * B * A^T; C, D lower triangular +""" +function blasfeo_ssyr2k_ln(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyr2k_ln(m::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ssyr2k_lt(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B + alpha * B^T * A; C, D lower triangular +""" +function blasfeo_ssyr2k_lt(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyr2k_lt(m::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ssyr2k_un(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A * B^T + alpha * B * A^T; C, D upper triangular +""" +function blasfeo_ssyr2k_un(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyr2k_un(m::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ssyr2k_ut(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + +D <= beta * C + alpha * A^T * B + alpha * B^T * A; C, D upper triangular +""" +function blasfeo_ssyr2k_ut(m, k, alpha, sA, ai, aj, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyr2k_ut(m::Cint, k::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + sgemm_diag_left_ib(m, n, alpha, dA, pB, sdb, beta, pC, sdc, pD, sdd) + +D <= alpha * A * B + beta * C, with A diagonal (stored as strvec) +""" +function sgemm_diag_left_ib(m, n, alpha, dA, pB, sdb, beta, pC, sdc, pD, sdd) + @ccall blasfeo.sgemm_diag_left_ib(m::Cint, n::Cint, alpha::Cfloat, dA::Ptr{Cfloat}, pB::Ptr{Cfloat}, sdb::Cint, beta::Cfloat, pC::Ptr{Cfloat}, sdc::Cint, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function blasfeo_sgemm_dn(m, n, alpha, sA, ai, sB, bi, bj, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_sgemm_dn(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_svec}, ai::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_sgemm_nd(m, n, alpha, sA, ai, aj, sB, bi, beta, sC, ci, cj, sD, di, dj) + +D <= alpha * A * B + beta * C, with B diagonal (stored as strvec) +""" +function blasfeo_sgemm_nd(m, n, alpha, sA, ai, aj, sB, bi, beta, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_sgemm_nd(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_svec}, bi::Cint, beta::Cfloat, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_spotrf_l(m, sC, ci, cj, sD, di, dj) + +D <= chol( C ) ; C, D lower triangular +""" +function blasfeo_spotrf_l(m, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_spotrf_l(m::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_spotrf_l_mn(m, n, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_spotrf_l_mn(m::Cint, n::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_spotrf_u(m, sC, ci, cj, sD, di, dj) + +D <= chol( C ) ; C, D upper triangular +""" +function blasfeo_spotrf_u(m, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_spotrf_u(m::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ssyrk_spotrf_ln(m, k, sA, ai, aj, sB, bi, bj, sC, ci, cj, sD, di, dj) + +D <= chol( C + A * B' ) ; C, D lower triangular +""" +function blasfeo_ssyrk_spotrf_ln(m, k, sA, ai, aj, sB, bi, bj, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyrk_spotrf_ln(m::Cint, k::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_ssyrk_spotrf_ln_mn(m, n, k, sA, ai, aj, sB, bi, bj, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_ssyrk_spotrf_ln_mn(m::Cint, n::Cint, k::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_smat}, bi::Cint, bj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_sgetrf_np(m, n, sC, ci, cj, sD, di, dj) + +D <= lu( C ) ; no pivoting +""" +function blasfeo_sgetrf_np(m, n, sC, ci, cj, sD, di, dj) + @ccall blasfeo.blasfeo_sgetrf_np(m::Cint, n::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_sgetrf_rp(m, n, sC, ci, cj, sD, di, dj, ipiv) + +D <= lu( C ) ; row pivoting +""" +function blasfeo_sgetrf_rp(m, n, sC, ci, cj, sD, di, dj, ipiv) + @ccall blasfeo.blasfeo_sgetrf_rp(m::Cint, n::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint, ipiv::Ptr{Cint})::Cvoid +end + +""" + blasfeo_sgeqrf(m, n, sC, ci, cj, sD, di, dj, work) + +D <= qr( C ) +""" +function blasfeo_sgeqrf(m, n, sC, ci, cj, sD, di, dj, work) + @ccall blasfeo.blasfeo_sgeqrf(m::Cint, n::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint, work::Ptr{Cvoid})::Cvoid +end + +function blasfeo_sgeqrf_worksize(m, n) + @ccall blasfeo.blasfeo_sgeqrf_worksize(m::Cint, n::Cint)::Cint +end + +""" + blasfeo_sorglq_worksize(m, n, k) + +D <= Q factor, where C is the output of the LQ factorization +""" +function blasfeo_sorglq_worksize(m, n, k) + @ccall blasfeo.blasfeo_sorglq_worksize(m::Cint, n::Cint, k::Cint)::Cint +end + +function blasfeo_sorglq(m, n, k, sC, ci, cj, sD, di, dj, work) + @ccall blasfeo.blasfeo_sorglq(m::Cint, n::Cint, k::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint, work::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_sgelqf(m, n, sC, ci, cj, sD, di, dj, work) + +D <= lq( C ) +""" +function blasfeo_sgelqf(m, n, sC, ci, cj, sD, di, dj, work) + @ccall blasfeo.blasfeo_sgelqf(m::Cint, n::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint, work::Ptr{Cvoid})::Cvoid +end + +function blasfeo_sgelqf_worksize(m, n) + @ccall blasfeo.blasfeo_sgelqf_worksize(m::Cint, n::Cint)::Cint +end + +""" + blasfeo_sgelqf_pd(m, n, sC, ci, cj, sD, di, dj, work) + +D <= lq( C ), positive diagonal elements +""" +function blasfeo_sgelqf_pd(m, n, sC, ci, cj, sD, di, dj, work) + @ccall blasfeo.blasfeo_sgelqf_pd(m::Cint, n::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint, work::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_sgelqf_pd_la(m, n1, sL, li, lj, sA, ai, aj, work) + +[L, A] <= lq( [L, A] ), positive diagonal elements, array of matrices, with +L lower triangular, of size (m)x(m) +A full, of size (m)x(n1) +""" +function blasfeo_sgelqf_pd_la(m, n1, sL, li, lj, sA, ai, aj, work) + @ccall blasfeo.blasfeo_sgelqf_pd_la(m::Cint, n1::Cint, sL::Ptr{blasfeo_smat}, li::Cint, lj::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, work::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_sgelqf_pd_lla(m, n1, sL0, l0i, l0j, sL1, l1i, l1j, sA, ai, aj, work) + +[L, L, A] <= lq( [L, L, A] ), positive diagonal elements, array of matrices, with: +L lower triangular, of size (m)x(m) +A full, of size (m)x(n1) +""" +function blasfeo_sgelqf_pd_lla(m, n1, sL0, l0i, l0j, sL1, l1i, l1j, sA, ai, aj, work) + @ccall blasfeo.blasfeo_sgelqf_pd_lla(m::Cint, n1::Cint, sL0::Ptr{blasfeo_smat}, l0i::Cint, l0j::Cint, sL1::Ptr{blasfeo_smat}, l1i::Cint, l1j::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, work::Ptr{Cvoid})::Cvoid +end + +function dtrcp_l_lib(m, alpha, offsetA, A, sda, offsetB, B, sdb) + @ccall blasfeo.dtrcp_l_lib(m::Cint, alpha::Cdouble, offsetA::Cint, A::Ptr{Cdouble}, sda::Cint, offsetB::Cint, B::Ptr{Cdouble}, sdb::Cint)::Cvoid +end + +function dgead_lib(m, n, alpha, offsetA, A, sda, offsetB, B, sdb) + @ccall blasfeo.dgead_lib(m::Cint, n::Cint, alpha::Cdouble, offsetA::Cint, A::Ptr{Cdouble}, sda::Cint, offsetB::Cint, B::Ptr{Cdouble}, sdb::Cint)::Cvoid +end + +""" + ddiain_sqrt_lib(kmax, x, offset, pD, sdd) + +TODO remove ??? +""" +function ddiain_sqrt_lib(kmax, x, offset, pD, sdd) + @ccall blasfeo.ddiain_sqrt_lib(kmax::Cint, x::Ptr{Cdouble}, offset::Cint, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +""" + ddiareg_lib(kmax, reg, offset, pD, sdd) + +TODO ddiaad1 +""" +function ddiareg_lib(kmax, reg, offset, pD, sdd) + @ccall blasfeo.ddiareg_lib(kmax::Cint, reg::Cdouble, offset::Cint, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function dgetr_lib(m, n, alpha, offsetA, pA, sda, offsetC, pC, sdc) + @ccall blasfeo.dgetr_lib(m::Cint, n::Cint, alpha::Cdouble, offsetA::Cint, pA::Ptr{Cdouble}, sda::Cint, offsetC::Cint, pC::Ptr{Cdouble}, sdc::Cint)::Cvoid +end + +function dtrtr_l_lib(m, alpha, offsetA, pA, sda, offsetC, pC, sdc) + @ccall blasfeo.dtrtr_l_lib(m::Cint, alpha::Cdouble, offsetA::Cint, pA::Ptr{Cdouble}, sda::Cint, offsetC::Cint, pC::Ptr{Cdouble}, sdc::Cint)::Cvoid +end + +function dtrtr_u_lib(m, alpha, offsetA, pA, sda, offsetC, pC, sdc) + @ccall blasfeo.dtrtr_u_lib(m::Cint, alpha::Cdouble, offsetA::Cint, pA::Ptr{Cdouble}, sda::Cint, offsetC::Cint, pC::Ptr{Cdouble}, sdc::Cint)::Cvoid +end + +function ddiaex_lib(kmax, alpha, offset, pD, sdd, x) + @ccall blasfeo.ddiaex_lib(kmax::Cint, alpha::Cdouble, offset::Cint, pD::Ptr{Cdouble}, sdd::Cint, x::Ptr{Cdouble})::Cvoid +end + +function ddiaad_lib(kmax, alpha, x, offset, pD, sdd) + @ccall blasfeo.ddiaad_lib(kmax::Cint, alpha::Cdouble, x::Ptr{Cdouble}, offset::Cint, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function ddiain_libsp(kmax, idx, alpha, x, pD, sdd) + @ccall blasfeo.ddiain_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cdouble, x::Ptr{Cdouble}, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function ddiaex_libsp(kmax, idx, alpha, pD, sdd, x) + @ccall blasfeo.ddiaex_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cdouble, pD::Ptr{Cdouble}, sdd::Cint, x::Ptr{Cdouble})::Cvoid +end + +function ddiaad_libsp(kmax, idx, alpha, x, pD, sdd) + @ccall blasfeo.ddiaad_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cdouble, x::Ptr{Cdouble}, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function ddiaadin_libsp(kmax, idx, alpha, x, y, pD, sdd) + @ccall blasfeo.ddiaadin_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cdouble, x::Ptr{Cdouble}, y::Ptr{Cdouble}, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function drowin_lib(kmax, alpha, x, pD) + @ccall blasfeo.drowin_lib(kmax::Cint, alpha::Cdouble, x::Ptr{Cdouble}, pD::Ptr{Cdouble})::Cvoid +end + +function drowex_lib(kmax, alpha, pD, x) + @ccall blasfeo.drowex_lib(kmax::Cint, alpha::Cdouble, pD::Ptr{Cdouble}, x::Ptr{Cdouble})::Cvoid +end + +function drowad_lib(kmax, alpha, x, pD) + @ccall blasfeo.drowad_lib(kmax::Cint, alpha::Cdouble, x::Ptr{Cdouble}, pD::Ptr{Cdouble})::Cvoid +end + +function drowin_libsp(kmax, alpha, idx, x, pD) + @ccall blasfeo.drowin_libsp(kmax::Cint, alpha::Cdouble, idx::Ptr{Cint}, x::Ptr{Cdouble}, pD::Ptr{Cdouble})::Cvoid +end + +function drowad_libsp(kmax, idx, alpha, x, pD) + @ccall blasfeo.drowad_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cdouble, x::Ptr{Cdouble}, pD::Ptr{Cdouble})::Cvoid +end + +function drowadin_libsp(kmax, idx, alpha, x, y, pD) + @ccall blasfeo.drowadin_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cdouble, x::Ptr{Cdouble}, y::Ptr{Cdouble}, pD::Ptr{Cdouble})::Cvoid +end + +function dcolin_lib(kmax, x, offset, pD, sdd) + @ccall blasfeo.dcolin_lib(kmax::Cint, x::Ptr{Cdouble}, offset::Cint, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function dcolad_lib(kmax, alpha, x, offset, pD, sdd) + @ccall blasfeo.dcolad_lib(kmax::Cint, alpha::Cdouble, x::Ptr{Cdouble}, offset::Cint, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function dcolin_libsp(kmax, idx, x, pD, sdd) + @ccall blasfeo.dcolin_libsp(kmax::Cint, idx::Ptr{Cint}, x::Ptr{Cdouble}, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function dcolad_libsp(kmax, alpha, idx, x, pD, sdd) + @ccall blasfeo.dcolad_libsp(kmax::Cint, alpha::Cdouble, idx::Ptr{Cint}, x::Ptr{Cdouble}, pD::Ptr{Cdouble}, sdd::Cint)::Cvoid +end + +function dcolsw_lib(kmax, offsetA, pA, sda, offsetC, pC, sdc) + @ccall blasfeo.dcolsw_lib(kmax::Cint, offsetA::Cint, pA::Ptr{Cdouble}, sda::Cint, offsetC::Cint, pC::Ptr{Cdouble}, sdc::Cint)::Cvoid +end + +function dvecin_libsp(kmax, idx, x, y) + @ccall blasfeo.dvecin_libsp(kmax::Cint, idx::Ptr{Cint}, x::Ptr{Cdouble}, y::Ptr{Cdouble})::Cvoid +end + +function dvecad_libsp(kmax, idx, alpha, x, y) + @ccall blasfeo.dvecad_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cdouble, x::Ptr{Cdouble}, y::Ptr{Cdouble})::Cvoid +end + +""" + blasfeo_memsize_dmat(m, n) + +--- memory size calculations + +returns the memory size (in bytes) needed for a dmat +""" +function blasfeo_memsize_dmat(m, n) + @ccall blasfeo.blasfeo_memsize_dmat(m::Cint, n::Cint)::Csize_t +end + +""" + blasfeo_memsize_diag_dmat(m, n) + +returns the memory size (in bytes) needed for the diagonal of a dmat +""" +function blasfeo_memsize_diag_dmat(m, n) + @ccall blasfeo.blasfeo_memsize_diag_dmat(m::Cint, n::Cint)::Csize_t +end + +""" + blasfeo_memsize_dvec(m) + +returns the memory size (in bytes) needed for a dvec +""" +function blasfeo_memsize_dvec(m) + @ccall blasfeo.blasfeo_memsize_dvec(m::Cint)::Csize_t +end + +""" + blasfeo_create_dmat(m, n, sA, memory) + +--- creation + +create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +""" +function blasfeo_create_dmat(m, n, sA, memory) + @ccall blasfeo.blasfeo_create_dmat(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, memory::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_create_dvec(m, sA, memory) + +create a strvec for a vector of size m by using memory passed by a pointer (pointer is not updated) +""" +function blasfeo_create_dvec(m, sA, memory) + @ccall blasfeo.blasfeo_create_dvec(m::Cint, sA::Ptr{blasfeo_dvec}, memory::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_pack_dmat(m, n, A, lda, sB, bi, bj) + +--- packing +pack the column-major matrix A (with leading dimension lda) into the matrix struct B (at row and col offsets bi and bj) +""" +function blasfeo_pack_dmat(m, n, A, lda, sB, bi, bj) + @ccall blasfeo.blasfeo_pack_dmat(m::Cint, n::Cint, A::Ptr{Cdouble}, lda::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_pack_l_dmat(m, n, A, lda, sB, bi, bj) + +pack the lower-triangular column-major matrix A (with leading dimension lda) into the matrix struct B (at row and col offsets bi and bj) +""" +function blasfeo_pack_l_dmat(m, n, A, lda, sB, bi, bj) + @ccall blasfeo.blasfeo_pack_l_dmat(m::Cint, n::Cint, A::Ptr{Cdouble}, lda::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_pack_u_dmat(m, n, A, lda, sB, bi, bj) + +pack the upper-triangular column-major matrix A (with leading dimension lda) into the matrix struct B (at row and col offsets bi and bj) +""" +function blasfeo_pack_u_dmat(m, n, A, lda, sB, bi, bj) + @ccall blasfeo.blasfeo_pack_u_dmat(m::Cint, n::Cint, A::Ptr{Cdouble}, lda::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_pack_tran_dmat(m, n, A, lda, sB, bi, bj) + +transpose and pack the column-major matrix A (with leading dimension lda) into the matrix struct B (at row and col offsets bi and bj) +""" +function blasfeo_pack_tran_dmat(m, n, A, lda, sB, bi, bj) + @ccall blasfeo.blasfeo_pack_tran_dmat(m::Cint, n::Cint, A::Ptr{Cdouble}, lda::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_pack_dvec(m, x, incx, sy, yi) + +pack the vector x (using increment incx) into the vector structure y (at offset yi) +""" +function blasfeo_pack_dvec(m, x, incx, sy, yi) + @ccall blasfeo.blasfeo_pack_dvec(m::Cint, x::Ptr{Cdouble}, incx::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint)::Cvoid +end + +""" + blasfeo_unpack_dmat(m, n, sA, ai, aj, B, ldb) + +unpack the matrix structure A (at row and col offsets ai and aj) into the column-major matrix B (with leading dimension ldb) +""" +function blasfeo_unpack_dmat(m, n, sA, ai, aj, B, ldb) + @ccall blasfeo.blasfeo_unpack_dmat(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, B::Ptr{Cdouble}, ldb::Cint)::Cvoid +end + +""" + blasfeo_unpack_tran_dmat(m, n, sA, ai, aj, B, ldb) + +transpose and unpack the matrix structure A (at row and col offsets ai and aj) into the column-major matrix B (with leading dimension ldb) +""" +function blasfeo_unpack_tran_dmat(m, n, sA, ai, aj, B, ldb) + @ccall blasfeo.blasfeo_unpack_tran_dmat(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, B::Ptr{Cdouble}, ldb::Cint)::Cvoid +end + +""" + blasfeo_unpack_dvec(m, sx, xi, y, incy) + +unpack the vector structure x (at offset xi) into the vector y (using increment incy) +""" +function blasfeo_unpack_dvec(m, sx, xi, y, incy) + @ccall blasfeo.blasfeo_unpack_dvec(m::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, y::Ptr{Cdouble}, incy::Cint)::Cvoid +end + +""" + blasfeo_dgein1(a, sA, ai, aj) + +ge +--- insert/extract + +sA[ai, aj] <= a +""" +function blasfeo_dgein1(a, sA, ai, aj) + @ccall blasfeo.blasfeo_dgein1(a::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_dgeex1(sA, ai, aj) + +<= sA[ai, aj] +""" +function blasfeo_dgeex1(sA, ai, aj) + @ccall blasfeo.blasfeo_dgeex1(sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cdouble +end + +""" + blasfeo_dgese(m, n, alpha, sA, ai, aj) + +--- set +A <= alpha +""" +function blasfeo_dgese(m, n, alpha, sA, ai, aj) + @ccall blasfeo.blasfeo_dgese(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_dgecp(m, n, sA, ai, aj, sB, bi, bj) + +--- copy / scale +B <= A +""" +function blasfeo_dgecp(m, n, sA, ai, aj, sB, bi, bj) + @ccall blasfeo.blasfeo_dgecp(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_dgesc(m, n, alpha, sA, ai, aj) + +A <= alpha*A +""" +function blasfeo_dgesc(m, n, alpha, sA, ai, aj) + @ccall blasfeo.blasfeo_dgesc(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_dgecpsc(m, n, alpha, sA, ai, aj, sB, bi, bj) + +B <= alpha*A +""" +function blasfeo_dgecpsc(m, n, alpha, sA, ai, aj, sB, bi, bj) + @ccall blasfeo.blasfeo_dgecpsc(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_dtrcp_l(m, sA, ai, aj, sB, bi, bj) + +B <= A, A lower triangular +""" +function blasfeo_dtrcp_l(m, sA, ai, aj, sB, bi, bj) + @ccall blasfeo.blasfeo_dtrcp_l(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +function blasfeo_dtrcpsc_l(m, alpha, sA, ai, aj, sB, bi, bj) + @ccall blasfeo.blasfeo_dtrcpsc_l(m::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +function blasfeo_dtrsc_l(m, alpha, sA, ai, aj) + @ccall blasfeo.blasfeo_dtrsc_l(m::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_dgead(m, n, alpha, sA, ai, aj, sB, bi, bj) + +--- sum +B <= B + alpha*A +""" +function blasfeo_dgead(m, n, alpha, sA, ai, aj, sB, bi, bj) + @ccall blasfeo.blasfeo_dgead(m::Cint, n::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_dvecad(m, alpha, sx, xi, sy, yi) + +y <= y + alpha*x +""" +function blasfeo_dvecad(m, alpha, sx, xi, sy, yi) + @ccall blasfeo.blasfeo_dvecad(m::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint)::Cvoid +end + +""" + blasfeo_dgetr(m, n, sA, ai, aj, sB, bi, bj) + +--- traspositions +B <= A' +""" +function blasfeo_dgetr(m, n, sA, ai, aj, sB, bi, bj) + @ccall blasfeo.blasfeo_dgetr(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_dtrtr_l(m, sA, ai, aj, sB, bi, bj) + +B <= A', A lower triangular +""" +function blasfeo_dtrtr_l(m, sA, ai, aj, sB, bi, bj) + @ccall blasfeo.blasfeo_dtrtr_l(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_dtrtr_u(m, sA, ai, aj, sB, bi, bj) + +B <= A', A upper triangular +""" +function blasfeo_dtrtr_u(m, sA, ai, aj, sB, bi, bj) + @ccall blasfeo.blasfeo_dtrtr_u(m::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sB::Ptr{blasfeo_dmat}, bi::Cint, bj::Cint)::Cvoid +end + +""" + blasfeo_ddiare(kmax, alpha, sA, ai, aj) + +dia +diag(A) += alpha +""" +function blasfeo_ddiare(kmax, alpha, sA, ai, aj) + @ccall blasfeo.blasfeo_ddiare(kmax::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_ddiain(kmax, alpha, sx, xi, sA, ai, aj) + +diag(A) <= alpha*x +""" +function blasfeo_ddiain(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_ddiain(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_ddiain_sp(kmax, alpha, sx, xi, idx, sD, di, dj) + +diag(A)[idx] <= alpha*x +""" +function blasfeo_ddiain_sp(kmax, alpha, sx, xi, idx, sD, di, dj) + @ccall blasfeo.blasfeo_ddiain_sp(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, idx::Ptr{Cint}, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ddiaex(kmax, alpha, sA, ai, aj, sx, xi) + +x <= diag(A) +""" +function blasfeo_ddiaex(kmax, alpha, sA, ai, aj, sx, xi) + @ccall blasfeo.blasfeo_ddiaex(kmax::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint)::Cvoid +end + +""" + blasfeo_ddiaex_sp(kmax, alpha, idx, sD, di, dj, sx, xi) + +x <= diag(A)[idx] +""" +function blasfeo_ddiaex_sp(kmax, alpha, idx, sD, di, dj, sx, xi) + @ccall blasfeo.blasfeo_ddiaex_sp(kmax::Cint, alpha::Cdouble, idx::Ptr{Cint}, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint)::Cvoid +end + +""" + blasfeo_ddiaad(kmax, alpha, sx, xi, sA, ai, aj) + +diag(A) += alpha*x +""" +function blasfeo_ddiaad(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_ddiaad(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_ddiaad_sp(kmax, alpha, sx, xi, idx, sD, di, dj) + +diag(A)[idx] += alpha*x +""" +function blasfeo_ddiaad_sp(kmax, alpha, sx, xi, idx, sD, di, dj) + @ccall blasfeo.blasfeo_ddiaad_sp(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, idx::Ptr{Cint}, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_ddiaadin_sp(kmax, alpha, sx, xi, sy, yi, idx, sD, di, dj) + +diag(A)[idx] = y + alpha*x +""" +function blasfeo_ddiaadin_sp(kmax, alpha, sx, xi, sy, yi, idx, sD, di, dj) + @ccall blasfeo.blasfeo_ddiaadin_sp(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint, idx::Ptr{Cint}, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_drowin(kmax, alpha, sx, xi, sA, ai, aj) + +row +""" +function blasfeo_drowin(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_drowin(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_drowex(kmax, alpha, sA, ai, aj, sx, xi) + @ccall blasfeo.blasfeo_drowex(kmax::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint)::Cvoid +end + +function blasfeo_drowad(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_drowad(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_drowad_sp(kmax, alpha, sx, xi, idx, sD, di, dj) + @ccall blasfeo.blasfeo_drowad_sp(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, idx::Ptr{Cint}, sD::Ptr{blasfeo_dmat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_drowsw(kmax, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_drowsw(kmax::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint)::Cvoid +end + +function blasfeo_drowpe(kmax, ipiv, sA) + @ccall blasfeo.blasfeo_drowpe(kmax::Cint, ipiv::Ptr{Cint}, sA::Ptr{blasfeo_dmat})::Cvoid +end + +function blasfeo_drowpei(kmax, ipiv, sA) + @ccall blasfeo.blasfeo_drowpei(kmax::Cint, ipiv::Ptr{Cint}, sA::Ptr{blasfeo_dmat})::Cvoid +end + +""" + blasfeo_dcolex(kmax, sA, ai, aj, sx, xi) + +col +""" +function blasfeo_dcolex(kmax, sA, ai, aj, sx, xi) + @ccall blasfeo.blasfeo_dcolex(kmax::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint)::Cvoid +end + +function blasfeo_dcolin(kmax, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_dcolin(kmax::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_dcolad(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_dcolad(kmax::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_dcolsc(kmax, alpha, sA, ai, aj) + @ccall blasfeo.blasfeo_dcolsc(kmax::Cint, alpha::Cdouble, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_dcolsw(kmax, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_dcolsw(kmax::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_dmat}, ci::Cint, cj::Cint)::Cvoid +end + +function blasfeo_dcolpe(kmax, ipiv, sA) + @ccall blasfeo.blasfeo_dcolpe(kmax::Cint, ipiv::Ptr{Cint}, sA::Ptr{blasfeo_dmat})::Cvoid +end + +function blasfeo_dcolpei(kmax, ipiv, sA) + @ccall blasfeo.blasfeo_dcolpei(kmax::Cint, ipiv::Ptr{Cint}, sA::Ptr{blasfeo_dmat})::Cvoid +end + +""" + blasfeo_dvecse(m, alpha, sx, xi) + +vec +a <= alpha +""" +function blasfeo_dvecse(m, alpha, sx, xi) + @ccall blasfeo.blasfeo_dvecse(m::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint)::Cvoid +end + +""" + blasfeo_dvecin1(a, sx, xi) + +sx[xi] <= a +""" +function blasfeo_dvecin1(a, sx, xi) + @ccall blasfeo.blasfeo_dvecin1(a::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint)::Cvoid +end + +""" + blasfeo_dvecex1(sx, xi) + +<= sx[xi] +""" +function blasfeo_dvecex1(sx, xi) + @ccall blasfeo.blasfeo_dvecex1(sx::Ptr{blasfeo_dvec}, xi::Cint)::Cdouble +end + +""" + blasfeo_dveccp(m, sx, xi, sy, yi) + +y <= x +""" +function blasfeo_dveccp(m, sx, xi, sy, yi) + @ccall blasfeo.blasfeo_dveccp(m::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint)::Cvoid +end + +""" + blasfeo_dvecsc(m, alpha, sx, xi) + +x <= alpha*x +""" +function blasfeo_dvecsc(m, alpha, sx, xi) + @ccall blasfeo.blasfeo_dvecsc(m::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint)::Cvoid +end + +""" + blasfeo_dveccpsc(m, alpha, sx, xi, sy, yi) + +y <= alpha*x +""" +function blasfeo_dveccpsc(m, alpha, sx, xi, sy, yi) + @ccall blasfeo.blasfeo_dveccpsc(m::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, sy::Ptr{blasfeo_dvec}, yi::Cint)::Cvoid +end + +""" + blasfeo_dvecad_sp(m, alpha, sx, xi, idx, sz, zi) + +z[idx] += alpha * x +""" +function blasfeo_dvecad_sp(m, alpha, sx, xi, idx, sz, zi) + @ccall blasfeo.blasfeo_dvecad_sp(m::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, idx::Ptr{Cint}, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dvecin_sp(m, alpha, sx, xi, idx, sz, zi) + +z[idx] <= alpha * x +""" +function blasfeo_dvecin_sp(m, alpha, sx, xi, idx, sz, zi) + @ccall blasfeo.blasfeo_dvecin_sp(m::Cint, alpha::Cdouble, sx::Ptr{blasfeo_dvec}, xi::Cint, idx::Ptr{Cint}, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dvecex_sp(m, alpha, idx, sx, xi, sz, zi) + +z <= alpha * x[idx] +""" +function blasfeo_dvecex_sp(m, alpha, idx, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dvecex_sp(m::Cint, alpha::Cdouble, idx::Ptr{Cint}, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +""" + blasfeo_dvecexad_sp(m, alpha, idx, sx, xi, sz, zi) + +z += alpha * x[idx] +""" +function blasfeo_dvecexad_sp(m, alpha, idx, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_dvecexad_sp(m::Cint, alpha::Cdouble, idx::Ptr{Cint}, sx::Ptr{blasfeo_dvec}, xi::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +function blasfeo_dveccl(m, sxm, xim, sx, xi, sxp, xip, sz, zi) + @ccall blasfeo.blasfeo_dveccl(m::Cint, sxm::Ptr{blasfeo_dvec}, xim::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sxp::Ptr{blasfeo_dvec}, xip::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint)::Cvoid +end + +function blasfeo_dveccl_mask(m, sxm, xim, sx, xi, sxp, xip, sz, zi, sm, mi) + @ccall blasfeo.blasfeo_dveccl_mask(m::Cint, sxm::Ptr{blasfeo_dvec}, xim::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, sxp::Ptr{blasfeo_dvec}, xip::Cint, sz::Ptr{blasfeo_dvec}, zi::Cint, sm::Ptr{blasfeo_dvec}, mi::Cint)::Cvoid +end + +function blasfeo_dvecze(m, sm, mi, sv, vi, se, ei) + @ccall blasfeo.blasfeo_dvecze(m::Cint, sm::Ptr{blasfeo_dvec}, mi::Cint, sv::Ptr{blasfeo_dvec}, vi::Cint, se::Ptr{blasfeo_dvec}, ei::Cint)::Cvoid +end + +function blasfeo_dvecnrm_inf(m, sx, xi, ptr_norm) + @ccall blasfeo.blasfeo_dvecnrm_inf(m::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, ptr_norm::Ptr{Cdouble})::Cvoid +end + +function blasfeo_dvecnrm_2(m, sx, xi, ptr_norm) + @ccall blasfeo.blasfeo_dvecnrm_2(m::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, ptr_norm::Ptr{Cdouble})::Cvoid +end + +function blasfeo_dvecnrm_1(m, sx, xi, ptr_norm) + @ccall blasfeo.blasfeo_dvecnrm_1(m::Cint, sx::Ptr{blasfeo_dvec}, xi::Cint, ptr_norm::Ptr{Cdouble})::Cvoid +end + +function blasfeo_dvecpe(kmax, ipiv, sx, xi) + @ccall blasfeo.blasfeo_dvecpe(kmax::Cint, ipiv::Ptr{Cint}, sx::Ptr{blasfeo_dvec}, xi::Cint)::Cvoid +end + +function blasfeo_dvecpei(kmax, ipiv, sx, xi) + @ccall blasfeo.blasfeo_dvecpei(kmax::Cint, ipiv::Ptr{Cint}, sx::Ptr{blasfeo_dvec}, xi::Cint)::Cvoid +end + +""" + blasfeo_pm_memsize_dmat(ps, m, n) + +returns the memory size (in bytes) needed for a dmat +""" +function blasfeo_pm_memsize_dmat(ps, m, n) + @ccall blasfeo.blasfeo_pm_memsize_dmat(ps::Cint, m::Cint, n::Cint)::Csize_t +end + +""" + blasfeo_pm_create_dmat(ps, m, n, sA, memory) + +create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +""" +function blasfeo_pm_create_dmat(ps, m, n, sA, memory) + @ccall blasfeo.blasfeo_pm_create_dmat(ps::Cint, m::Cint, n::Cint, sA::Ptr{blasfeo_pm_dmat}, memory::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_pm_print_dmat(m, n, sA, ai, aj) + +print +""" +function blasfeo_pm_print_dmat(m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_pm_print_dmat(m::Cint, n::Cint, sA::Ptr{blasfeo_pm_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_cm_memsize_dmat(m, n) + +returns the memory size (in bytes) needed for a dmat +""" +function blasfeo_cm_memsize_dmat(m, n) + @ccall blasfeo.blasfeo_cm_memsize_dmat(m::Cint, n::Cint)::Csize_t +end + +""" + blasfeo_cm_create_dmat(m, n, sA, memory) + +create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +""" +function blasfeo_cm_create_dmat(m, n, sA, memory) + @ccall blasfeo.blasfeo_cm_create_dmat(m::Cint, n::Cint, sA::Ptr{blasfeo_pm_dmat}, memory::Ptr{Cvoid})::Cvoid +end + +""" + strcp_l_lib(m, alpha, offsetA, A, sda, offsetB, B, sdb) + +TODO remove +""" +function strcp_l_lib(m, alpha, offsetA, A, sda, offsetB, B, sdb) + @ccall blasfeo.strcp_l_lib(m::Cint, alpha::Cfloat, offsetA::Cint, A::Ptr{Cfloat}, sda::Cint, offsetB::Cint, B::Ptr{Cfloat}, sdb::Cint)::Cvoid +end + +function sgead_lib(m, n, alpha, offsetA, A, sda, offsetB, B, sdb) + @ccall blasfeo.sgead_lib(m::Cint, n::Cint, alpha::Cfloat, offsetA::Cint, A::Ptr{Cfloat}, sda::Cint, offsetB::Cint, B::Ptr{Cfloat}, sdb::Cint)::Cvoid +end + +function sgetr_lib(m, n, alpha, offsetA, pA, sda, offsetC, pC, sdc) + @ccall blasfeo.sgetr_lib(m::Cint, n::Cint, alpha::Cfloat, offsetA::Cint, pA::Ptr{Cfloat}, sda::Cint, offsetC::Cint, pC::Ptr{Cfloat}, sdc::Cint)::Cvoid +end + +function strtr_l_lib(m, alpha, offsetA, pA, sda, offsetC, pC, sdc) + @ccall blasfeo.strtr_l_lib(m::Cint, alpha::Cfloat, offsetA::Cint, pA::Ptr{Cfloat}, sda::Cint, offsetC::Cint, pC::Ptr{Cfloat}, sdc::Cint)::Cvoid +end + +function strtr_u_lib(m, alpha, offsetA, pA, sda, offsetC, pC, sdc) + @ccall blasfeo.strtr_u_lib(m::Cint, alpha::Cfloat, offsetA::Cint, pA::Ptr{Cfloat}, sda::Cint, offsetC::Cint, pC::Ptr{Cfloat}, sdc::Cint)::Cvoid +end + +function sdiareg_lib(kmax, reg, offset, pD, sdd) + @ccall blasfeo.sdiareg_lib(kmax::Cint, reg::Cfloat, offset::Cint, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function sdiain_sqrt_lib(kmax, x, offset, pD, sdd) + @ccall blasfeo.sdiain_sqrt_lib(kmax::Cint, x::Ptr{Cfloat}, offset::Cint, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function sdiaex_lib(kmax, alpha, offset, pD, sdd, x) + @ccall blasfeo.sdiaex_lib(kmax::Cint, alpha::Cfloat, offset::Cint, pD::Ptr{Cfloat}, sdd::Cint, x::Ptr{Cfloat})::Cvoid +end + +function sdiaad_lib(kmax, alpha, x, offset, pD, sdd) + @ccall blasfeo.sdiaad_lib(kmax::Cint, alpha::Cfloat, x::Ptr{Cfloat}, offset::Cint, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function sdiain_libsp(kmax, idx, alpha, x, pD, sdd) + @ccall blasfeo.sdiain_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cfloat, x::Ptr{Cfloat}, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function sdiaex_libsp(kmax, idx, alpha, pD, sdd, x) + @ccall blasfeo.sdiaex_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cfloat, pD::Ptr{Cfloat}, sdd::Cint, x::Ptr{Cfloat})::Cvoid +end + +function sdiaad_libsp(kmax, idx, alpha, x, pD, sdd) + @ccall blasfeo.sdiaad_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cfloat, x::Ptr{Cfloat}, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function sdiaadin_libsp(kmax, idx, alpha, x, y, pD, sdd) + @ccall blasfeo.sdiaadin_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cfloat, x::Ptr{Cfloat}, y::Ptr{Cfloat}, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function srowin_lib(kmax, alpha, x, pD) + @ccall blasfeo.srowin_lib(kmax::Cint, alpha::Cfloat, x::Ptr{Cfloat}, pD::Ptr{Cfloat})::Cvoid +end + +function srowex_lib(kmax, alpha, pD, x) + @ccall blasfeo.srowex_lib(kmax::Cint, alpha::Cfloat, pD::Ptr{Cfloat}, x::Ptr{Cfloat})::Cvoid +end + +function srowad_lib(kmax, alpha, x, pD) + @ccall blasfeo.srowad_lib(kmax::Cint, alpha::Cfloat, x::Ptr{Cfloat}, pD::Ptr{Cfloat})::Cvoid +end + +function srowin_libsp(kmax, alpha, idx, x, pD) + @ccall blasfeo.srowin_libsp(kmax::Cint, alpha::Cfloat, idx::Ptr{Cint}, x::Ptr{Cfloat}, pD::Ptr{Cfloat})::Cvoid +end + +function srowad_libsp(kmax, idx, alpha, x, pD) + @ccall blasfeo.srowad_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cfloat, x::Ptr{Cfloat}, pD::Ptr{Cfloat})::Cvoid +end + +function srowadin_libsp(kmax, idx, alpha, x, y, pD) + @ccall blasfeo.srowadin_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cfloat, x::Ptr{Cfloat}, y::Ptr{Cfloat}, pD::Ptr{Cfloat})::Cvoid +end + +function srowsw_lib(kmax, pA, pC) + @ccall blasfeo.srowsw_lib(kmax::Cint, pA::Ptr{Cfloat}, pC::Ptr{Cfloat})::Cvoid +end + +function scolin_lib(kmax, x, offset, pD, sdd) + @ccall blasfeo.scolin_lib(kmax::Cint, x::Ptr{Cfloat}, offset::Cint, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function scolad_lib(kmax, alpha, x, offset, pD, sdd) + @ccall blasfeo.scolad_lib(kmax::Cint, alpha::Cfloat, x::Ptr{Cfloat}, offset::Cint, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function scolin_libsp(kmax, idx, x, pD, sdd) + @ccall blasfeo.scolin_libsp(kmax::Cint, idx::Ptr{Cint}, x::Ptr{Cfloat}, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function scolad_libsp(kmax, alpha, idx, x, pD, sdd) + @ccall blasfeo.scolad_libsp(kmax::Cint, alpha::Cfloat, idx::Ptr{Cint}, x::Ptr{Cfloat}, pD::Ptr{Cfloat}, sdd::Cint)::Cvoid +end + +function scolsw_lib(kmax, offsetA, pA, sda, offsetC, pC, sdc) + @ccall blasfeo.scolsw_lib(kmax::Cint, offsetA::Cint, pA::Ptr{Cfloat}, sda::Cint, offsetC::Cint, pC::Ptr{Cfloat}, sdc::Cint)::Cvoid +end + +function svecin_libsp(kmax, idx, x, y) + @ccall blasfeo.svecin_libsp(kmax::Cint, idx::Ptr{Cint}, x::Ptr{Cfloat}, y::Ptr{Cfloat})::Cvoid +end + +function svecad_libsp(kmax, idx, alpha, x, y) + @ccall blasfeo.svecad_libsp(kmax::Cint, idx::Ptr{Cint}, alpha::Cfloat, x::Ptr{Cfloat}, y::Ptr{Cfloat})::Cvoid +end + +""" + blasfeo_memsize_smat(m, n) + +memory +returns the memory size (in bytes) needed for a smat +""" +function blasfeo_memsize_smat(m, n) + @ccall blasfeo.blasfeo_memsize_smat(m::Cint, n::Cint)::Csize_t +end + +""" + blasfeo_memsize_diag_smat(m, n) + +returns the memory size (in bytes) needed for the diagonal of a smat +""" +function blasfeo_memsize_diag_smat(m, n) + @ccall blasfeo.blasfeo_memsize_diag_smat(m::Cint, n::Cint)::Csize_t +end + +""" + blasfeo_memsize_svec(m) + +returns the memory size (in bytes) needed for a svec +""" +function blasfeo_memsize_svec(m) + @ccall blasfeo.blasfeo_memsize_svec(m::Cint)::Csize_t +end + +""" + blasfeo_create_smat(m, n, sA, memory) + +creation +create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +""" +function blasfeo_create_smat(m, n, sA, memory) + @ccall blasfeo.blasfeo_create_smat(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, memory::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_create_svec(m, sA, memory) + +create a strvec for a vector of size m by using memory passed by a pointer (pointer is not updated) +""" +function blasfeo_create_svec(m, sA, memory) + @ccall blasfeo.blasfeo_create_svec(m::Cint, sA::Ptr{blasfeo_svec}, memory::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_pack_smat(m, n, A, lda, sA, ai, aj) + +packing +pack the column-major matrix A (with leading dimension lda) into the matrix struct B (at row and col offsets bi and bj) +""" +function blasfeo_pack_smat(m, n, A, lda, sA, ai, aj) + @ccall blasfeo.blasfeo_pack_smat(m::Cint, n::Cint, A::Ptr{Cfloat}, lda::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_pack_l_smat(m, n, A, lda, sA, ai, aj) + +pack the lower-triangular column-major matrix A (with leading dimension lda) into the matrix struct B (at row and col offsets bi and bj) +""" +function blasfeo_pack_l_smat(m, n, A, lda, sA, ai, aj) + @ccall blasfeo.blasfeo_pack_l_smat(m::Cint, n::Cint, A::Ptr{Cfloat}, lda::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_pack_u_smat(m, n, A, lda, sA, ai, aj) + +pack the upper-triangular column-major matrix A (with leading dimension lda) into the matrix struct B (at row and col offsets bi and bj) +""" +function blasfeo_pack_u_smat(m, n, A, lda, sA, ai, aj) + @ccall blasfeo.blasfeo_pack_u_smat(m::Cint, n::Cint, A::Ptr{Cfloat}, lda::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_pack_tran_smat(m, n, A, lda, sA, ai, aj) + +transpose and pack the column-major matrix A (with leading dimension lda) into the matrix struct B (at row and col offsets bi and bj) +""" +function blasfeo_pack_tran_smat(m, n, A, lda, sA, ai, aj) + @ccall blasfeo.blasfeo_pack_tran_smat(m::Cint, n::Cint, A::Ptr{Cfloat}, lda::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_pack_svec(m, x, xi, sa, ai) + +pack the vector x (using increment incx) into the vector structure y (at offset yi) +""" +function blasfeo_pack_svec(m, x, xi, sa, ai) + @ccall blasfeo.blasfeo_pack_svec(m::Cint, x::Ptr{Cfloat}, xi::Cint, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +""" + blasfeo_unpack_smat(m, n, sA, ai, aj, A, lda) + +unpack the matrix structure A (at row and col offsets ai and aj) into the column-major matrix B (with leading dimension ldb) +""" +function blasfeo_unpack_smat(m, n, sA, ai, aj, A, lda) + @ccall blasfeo.blasfeo_unpack_smat(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + blasfeo_unpack_tran_smat(m, n, sA, ai, aj, A, lda) + +transpose and unpack the matrix structure A (at row and col offsets ai and aj) into the column-major matrix B (with leading dimension ldb) +""" +function blasfeo_unpack_tran_smat(m, n, sA, ai, aj, A, lda) + @ccall blasfeo.blasfeo_unpack_tran_smat(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + blasfeo_unpack_svec(m, sa, ai, x, xi) + +unpack the vector structure x (at offset xi) into the vector y (using increment incy) +""" +function blasfeo_unpack_svec(m, sa, ai, x, xi) + @ccall blasfeo.blasfeo_unpack_svec(m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint, x::Ptr{Cfloat}, xi::Cint)::Cvoid +end + +""" + blasfeo_sgese(m, n, alpha, sA, ai, aj) + +ge +""" +function blasfeo_sgese(m, n, alpha, sA, ai, aj) + @ccall blasfeo.blasfeo_sgese(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_sgecpsc(m, n, alpha, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_sgecpsc(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint)::Cvoid +end + +function blasfeo_sgecp(m, n, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_sgecp(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint)::Cvoid +end + +function blasfeo_sgesc(m, n, alpha, sA, ai, aj) + @ccall blasfeo.blasfeo_sgesc(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_sgein1(a, sA, ai, aj) + @ccall blasfeo.blasfeo_sgein1(a::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_sgeex1(sA, ai, aj) + @ccall blasfeo.blasfeo_sgeex1(sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cfloat +end + +function blasfeo_sgead(m, n, alpha, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_sgead(m::Cint, n::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint)::Cvoid +end + +function blasfeo_sgetr(m, n, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_sgetr(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint)::Cvoid +end + +""" + blasfeo_strcp_l(m, sA, ai, aj, sC, ci, cj) + +tr +""" +function blasfeo_strcp_l(m, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_strcp_l(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint)::Cvoid +end + +function blasfeo_strtr_l(m, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_strtr_l(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint)::Cvoid +end + +function blasfeo_strtr_u(m, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_strtr_u(m::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint)::Cvoid +end + +""" + blasfeo_sdiare(kmax, alpha, sA, ai, aj) + +dia +""" +function blasfeo_sdiare(kmax, alpha, sA, ai, aj) + @ccall blasfeo.blasfeo_sdiare(kmax::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_sdiaex(kmax, alpha, sA, ai, aj, sx, xi) + @ccall blasfeo.blasfeo_sdiaex(kmax::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint)::Cvoid +end + +function blasfeo_sdiain(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_sdiain(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_sdiain_sp(kmax, alpha, sx, xi, idx, sD, di, dj) + @ccall blasfeo.blasfeo_sdiain_sp(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, idx::Ptr{Cint}, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_sdiaex_sp(kmax, alpha, idx, sD, di, dj, sx, xi) + @ccall blasfeo.blasfeo_sdiaex_sp(kmax::Cint, alpha::Cfloat, idx::Ptr{Cint}, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint)::Cvoid +end + +function blasfeo_sdiaad(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_sdiaad(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_sdiaad_sp(kmax, alpha, sx, xi, idx, sD, di, dj) + @ccall blasfeo.blasfeo_sdiaad_sp(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, idx::Ptr{Cint}, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_sdiaadin_sp(kmax, alpha, sx, xi, sy, yi, idx, sD, di, dj) + @ccall blasfeo.blasfeo_sdiaadin_sp(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, sy::Ptr{blasfeo_svec}, yi::Cint, idx::Ptr{Cint}, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +""" + blasfeo_srowin(kmax, alpha, sx, xi, sA, ai, aj) + +row +""" +function blasfeo_srowin(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_srowin(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_srowex(kmax, alpha, sA, ai, aj, sx, xi) + @ccall blasfeo.blasfeo_srowex(kmax::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint)::Cvoid +end + +function blasfeo_srowad(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_srowad(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_srowad_sp(kmax, alpha, sx, xi, idx, sD, di, dj) + @ccall blasfeo.blasfeo_srowad_sp(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, idx::Ptr{Cint}, sD::Ptr{blasfeo_smat}, di::Cint, dj::Cint)::Cvoid +end + +function blasfeo_srowsw(kmax, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_srowsw(kmax::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint)::Cvoid +end + +function blasfeo_srowpe(kmax, ipiv, sA) + @ccall blasfeo.blasfeo_srowpe(kmax::Cint, ipiv::Ptr{Cint}, sA::Ptr{blasfeo_smat})::Cvoid +end + +function blasfeo_srowpei(kmax, ipiv, sA) + @ccall blasfeo.blasfeo_srowpei(kmax::Cint, ipiv::Ptr{Cint}, sA::Ptr{blasfeo_smat})::Cvoid +end + +""" + blasfeo_scolex(kmax, sA, ai, aj, sx, xi) + +col +""" +function blasfeo_scolex(kmax, sA, ai, aj, sx, xi) + @ccall blasfeo.blasfeo_scolex(kmax::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sx::Ptr{blasfeo_svec}, xi::Cint)::Cvoid +end + +function blasfeo_scolin(kmax, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_scolin(kmax::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_scolad(kmax, alpha, sx, xi, sA, ai, aj) + @ccall blasfeo.blasfeo_scolad(kmax::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_scolsc(kmax, alpha, sA, ai, aj) + @ccall blasfeo.blasfeo_scolsc(kmax::Cint, alpha::Cfloat, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +function blasfeo_scolsw(kmax, sA, ai, aj, sC, ci, cj) + @ccall blasfeo.blasfeo_scolsw(kmax::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint, sC::Ptr{blasfeo_smat}, ci::Cint, cj::Cint)::Cvoid +end + +function blasfeo_scolpe(kmax, ipiv, sA) + @ccall blasfeo.blasfeo_scolpe(kmax::Cint, ipiv::Ptr{Cint}, sA::Ptr{blasfeo_smat})::Cvoid +end + +function blasfeo_scolpei(kmax, ipiv, sA) + @ccall blasfeo.blasfeo_scolpei(kmax::Cint, ipiv::Ptr{Cint}, sA::Ptr{blasfeo_smat})::Cvoid +end + +""" + blasfeo_svecse(m, alpha, sx, xi) + +vec +""" +function blasfeo_svecse(m, alpha, sx, xi) + @ccall blasfeo.blasfeo_svecse(m::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint)::Cvoid +end + +function blasfeo_sveccp(m, sa, ai, sc, ci) + @ccall blasfeo.blasfeo_sveccp(m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint, sc::Ptr{blasfeo_svec}, ci::Cint)::Cvoid +end + +function blasfeo_svecsc(m, alpha, sa, ai) + @ccall blasfeo.blasfeo_svecsc(m::Cint, alpha::Cfloat, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +function blasfeo_sveccpsc(m, alpha, sa, ai, sc, ci) + @ccall blasfeo.blasfeo_sveccpsc(m::Cint, alpha::Cfloat, sa::Ptr{blasfeo_svec}, ai::Cint, sc::Ptr{blasfeo_svec}, ci::Cint)::Cvoid +end + +function blasfeo_svecad(m, alpha, sa, ai, sc, ci) + @ccall blasfeo.blasfeo_svecad(m::Cint, alpha::Cfloat, sa::Ptr{blasfeo_svec}, ai::Cint, sc::Ptr{blasfeo_svec}, ci::Cint)::Cvoid +end + +function blasfeo_svecin1(a, sx, xi) + @ccall blasfeo.blasfeo_svecin1(a::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint)::Cvoid +end + +function blasfeo_svecex1(sx, xi) + @ccall blasfeo.blasfeo_svecex1(sx::Ptr{blasfeo_svec}, xi::Cint)::Cfloat +end + +function blasfeo_svecad_sp(m, alpha, sx, xi, idx, sz, zi) + @ccall blasfeo.blasfeo_svecad_sp(m::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, idx::Ptr{Cint}, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +function blasfeo_svecin_sp(m, alpha, sx, xi, idx, sz, zi) + @ccall blasfeo.blasfeo_svecin_sp(m::Cint, alpha::Cfloat, sx::Ptr{blasfeo_svec}, xi::Cint, idx::Ptr{Cint}, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +function blasfeo_svecex_sp(m, alpha, idx, sx, x, sz, zi) + @ccall blasfeo.blasfeo_svecex_sp(m::Cint, alpha::Cfloat, idx::Ptr{Cint}, sx::Ptr{blasfeo_svec}, x::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +""" + blasfeo_svecexad_sp(m, alpha, idx, sx, xi, sz, zi) + +z += alpha * x[idx] +""" +function blasfeo_svecexad_sp(m, alpha, idx, sx, xi, sz, zi) + @ccall blasfeo.blasfeo_svecexad_sp(m::Cint, alpha::Cdouble, idx::Ptr{Cint}, sx::Ptr{blasfeo_svec}, xi::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +function blasfeo_sveccl(m, sxm, xim, sx, xi, sxp, xip, sz, zi) + @ccall blasfeo.blasfeo_sveccl(m::Cint, sxm::Ptr{blasfeo_svec}, xim::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sxp::Ptr{blasfeo_svec}, xip::Cint, sz::Ptr{blasfeo_svec}, zi::Cint)::Cvoid +end + +function blasfeo_sveccl_mask(m, sxm, xim, sx, xi, sxp, xip, sz, zi, sm, mi) + @ccall blasfeo.blasfeo_sveccl_mask(m::Cint, sxm::Ptr{blasfeo_svec}, xim::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, sxp::Ptr{blasfeo_svec}, xip::Cint, sz::Ptr{blasfeo_svec}, zi::Cint, sm::Ptr{blasfeo_svec}, mi::Cint)::Cvoid +end + +function blasfeo_svecze(m, sm, mi, sv, vi, se, ei) + @ccall blasfeo.blasfeo_svecze(m::Cint, sm::Ptr{blasfeo_svec}, mi::Cint, sv::Ptr{blasfeo_svec}, vi::Cint, se::Ptr{blasfeo_svec}, ei::Cint)::Cvoid +end + +function blasfeo_svecnrm_inf(m, sx, xi, ptr_norm) + @ccall blasfeo.blasfeo_svecnrm_inf(m::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, ptr_norm::Ptr{Cfloat})::Cvoid +end + +function blasfeo_svecnrm_2(m, sx, xi, ptr_norm) + @ccall blasfeo.blasfeo_svecnrm_2(m::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, ptr_norm::Ptr{Cfloat})::Cvoid +end + +function blasfeo_svecnrm_1(m, sx, xi, ptr_norm) + @ccall blasfeo.blasfeo_svecnrm_1(m::Cint, sx::Ptr{blasfeo_svec}, xi::Cint, ptr_norm::Ptr{Cfloat})::Cvoid +end + +function blasfeo_svecpe(kmax, ipiv, sx, xi) + @ccall blasfeo.blasfeo_svecpe(kmax::Cint, ipiv::Ptr{Cint}, sx::Ptr{blasfeo_svec}, xi::Cint)::Cvoid +end + +function blasfeo_svecpei(kmax, ipiv, sx, xi) + @ccall blasfeo.blasfeo_svecpei(kmax::Cint, ipiv::Ptr{Cint}, sx::Ptr{blasfeo_svec}, xi::Cint)::Cvoid +end + +""" + blasfeo_pm_memsize_smat(ps, m, n) + +returns the memory size (in bytes) needed for a dmat +""" +function blasfeo_pm_memsize_smat(ps, m, n) + @ccall blasfeo.blasfeo_pm_memsize_smat(ps::Cint, m::Cint, n::Cint)::Csize_t +end + +""" + blasfeo_pm_create_smat(ps, m, n, sA, memory) + +create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +""" +function blasfeo_pm_create_smat(ps, m, n, sA, memory) + @ccall blasfeo.blasfeo_pm_create_smat(ps::Cint, m::Cint, n::Cint, sA::Ptr{blasfeo_pm_smat}, memory::Ptr{Cvoid})::Cvoid +end + +""" + blasfeo_cm_memsize_smat(m, n) + +returns the memory size (in bytes) needed for a dmat +""" +function blasfeo_cm_memsize_smat(m, n) + @ccall blasfeo.blasfeo_cm_memsize_smat(m::Cint, n::Cint)::Csize_t +end + +""" + blasfeo_cm_create_smat(m, n, sA, memory) + +create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +""" +function blasfeo_cm_create_smat(m, n, sA, memory) + @ccall blasfeo.blasfeo_cm_create_smat(m::Cint, n::Cint, sA::Ptr{blasfeo_pm_smat}, memory::Ptr{Cvoid})::Cvoid +end + +""" + d_zeros(pA, row, col) + +dynamically allocate row*col doubles of memory and set accordingly a pointer to double; set allocated memory to zero +""" +function d_zeros(pA, row, col) + @ccall blasfeo.d_zeros(pA::Ptr{Ptr{Cdouble}}, row::Cint, col::Cint)::Cvoid +end + +""" + d_zeros_align(pA, row, col) + +dynamically allocate row*col doubles of memory aligned to 64-byte boundaries and set accordingly a pointer to double; set allocated memory to zero +""" +function d_zeros_align(pA, row, col) + @ccall blasfeo.d_zeros_align(pA::Ptr{Ptr{Cdouble}}, row::Cint, col::Cint)::Cvoid +end + +""" + d_zeros_align_bytes(pA, size) + +dynamically allocate size bytes of memory aligned to 64-byte boundaries and set accordingly a pointer to double; set allocated memory to zero +""" +function d_zeros_align_bytes(pA, size) + @ccall blasfeo.d_zeros_align_bytes(pA::Ptr{Ptr{Cdouble}}, size::Cint)::Cvoid +end + +""" + d_free(pA) + +free the memory allocated by d_zeros +""" +function d_free(pA) + @ccall blasfeo.d_free(pA::Ptr{Cdouble})::Cvoid +end + +""" + d_free_align(pA) + +free the memory allocated by d_zeros_align or d_zeros_align_bytes +""" +function d_free_align(pA) + @ccall blasfeo.d_free_align(pA::Ptr{Cdouble})::Cvoid +end + +""" + d_print_mat(m, n, A, lda) + +print a column-major matrix +""" +function d_print_mat(m, n, A, lda) + @ccall blasfeo.d_print_mat(m::Cint, n::Cint, A::Ptr{Cdouble}, lda::Cint)::Cvoid +end + +""" + d_print_exp_mat(m, n, A, lda) + +print in exponential notation a column-major matrix +""" +function d_print_exp_mat(m, n, A, lda) + @ccall blasfeo.d_print_exp_mat(m::Cint, n::Cint, A::Ptr{Cdouble}, lda::Cint)::Cvoid +end + +""" + d_print_tran_mat(row, col, A, lda) + +print the transposed of a column-major matrix +""" +function d_print_tran_mat(row, col, A, lda) + @ccall blasfeo.d_print_tran_mat(row::Cint, col::Cint, A::Ptr{Cdouble}, lda::Cint)::Cvoid +end + +""" + d_print_exp_tran_mat(row, col, A, lda) + +print in exponential notation the transposed of a column-major matrix +""" +function d_print_exp_tran_mat(row, col, A, lda) + @ccall blasfeo.d_print_exp_tran_mat(row::Cint, col::Cint, A::Ptr{Cdouble}, lda::Cint)::Cvoid +end + +""" + d_print_to_file_mat(file, row, col, A, lda) + +print to file a column-major matrix +""" +function d_print_to_file_mat(file, row, col, A, lda) + @ccall blasfeo.d_print_to_file_mat(file::Ptr{Libc.FILE}, row::Cint, col::Cint, A::Ptr{Cdouble}, lda::Cint)::Cvoid +end + +""" + d_print_to_file_exp_mat(file, row, col, A, lda) + +print to file a column-major matrix in exponential format +""" +function d_print_to_file_exp_mat(file, row, col, A, lda) + @ccall blasfeo.d_print_to_file_exp_mat(file::Ptr{Libc.FILE}, row::Cint, col::Cint, A::Ptr{Cdouble}, lda::Cint)::Cvoid +end + +""" + d_print_tran_to_file_mat(file, row, col, A, lda) + +print to file the transposed of a column-major matrix +""" +function d_print_tran_to_file_mat(file, row, col, A, lda) + @ccall blasfeo.d_print_tran_to_file_mat(file::Ptr{Libc.FILE}, row::Cint, col::Cint, A::Ptr{Cdouble}, lda::Cint)::Cvoid +end + +""" + d_print_tran_to_file_exp_mat(file, row, col, A, lda) + +print to file the transposed of a column-major matrix in exponential format +""" +function d_print_tran_to_file_exp_mat(file, row, col, A, lda) + @ccall blasfeo.d_print_tran_to_file_exp_mat(file::Ptr{Libc.FILE}, row::Cint, col::Cint, A::Ptr{Cdouble}, lda::Cint)::Cvoid +end + +""" + d_print_to_string_mat(buf_out, row, col, A, lda) + +print to string a column-major matrix +""" +function d_print_to_string_mat(buf_out, row, col, A, lda) + @ccall blasfeo.d_print_to_string_mat(buf_out::Ptr{Ptr{Cchar}}, row::Cint, col::Cint, A::Ptr{Cdouble}, lda::Cint)::Cvoid +end + +""" + blasfeo_allocate_dmat(m, n, sA) + +create a strmat for a matrix of size m*n by dynamically allocating memory +""" +function blasfeo_allocate_dmat(m, n, sA) + @ccall blasfeo.blasfeo_allocate_dmat(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat})::Cvoid +end + +""" + blasfeo_allocate_dvec(m, sa) + +create a strvec for a vector of size m by dynamically allocating memory +""" +function blasfeo_allocate_dvec(m, sa) + @ccall blasfeo.blasfeo_allocate_dvec(m::Cint, sa::Ptr{blasfeo_dvec})::Cvoid +end + +""" + blasfeo_free_dmat(sA) + +free the memory allocated by blasfeo_allocate_dmat +""" +function blasfeo_free_dmat(sA) + @ccall blasfeo.blasfeo_free_dmat(sA::Ptr{blasfeo_dmat})::Cvoid +end + +""" + blasfeo_free_dvec(sa) + +free the memory allocated by blasfeo_allocate_dvec +""" +function blasfeo_free_dvec(sa) + @ccall blasfeo.blasfeo_free_dvec(sa::Ptr{blasfeo_dvec})::Cvoid +end + +""" + blasfeo_print_dmat(m, n, sA, ai, aj) + +print a strmat +""" +function blasfeo_print_dmat(m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_dmat(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_exp_dmat(m, n, sA, ai, aj) + +print in exponential notation a strmat +""" +function blasfeo_print_exp_dmat(m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_exp_dmat(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_tran_dmat(m, n, sA, ai, aj) + +print the transposed of a strmat +""" +function blasfeo_print_tran_dmat(m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_tran_dmat(m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_dvec(m, sa, ai) + +print a strvec +""" +function blasfeo_print_dvec(m, sa, ai) + @ccall blasfeo.blasfeo_print_dvec(m::Cint, sa::Ptr{blasfeo_dvec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_exp_dvec(m, sa, ai) + +print in exponential notation a strvec +""" +function blasfeo_print_exp_dvec(m, sa, ai) + @ccall blasfeo.blasfeo_print_exp_dvec(m::Cint, sa::Ptr{blasfeo_dvec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_tran_dvec(m, sa, ai) + +print the transposed of a strvec +""" +function blasfeo_print_tran_dvec(m, sa, ai) + @ccall blasfeo.blasfeo_print_tran_dvec(m::Cint, sa::Ptr{blasfeo_dvec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_exp_tran_dvec(m, sa, ai) + +print in exponential notation the transposed of a strvec +""" +function blasfeo_print_exp_tran_dvec(m, sa, ai) + @ccall blasfeo.blasfeo_print_exp_tran_dvec(m::Cint, sa::Ptr{blasfeo_dvec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_to_file_dmat(file, m, n, sA, ai, aj) + +print to file a strmat +""" +function blasfeo_print_to_file_dmat(file, m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_to_file_dmat(file::Ptr{Libc.FILE}, m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_to_file_exp_dmat(file, m, n, sA, ai, aj) + +print to file a strmat in exponential format +""" +function blasfeo_print_to_file_exp_dmat(file, m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_to_file_exp_dmat(file::Ptr{Libc.FILE}, m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_to_file_dvec(file, m, sa, ai) + +print to file a strvec +""" +function blasfeo_print_to_file_dvec(file, m, sa, ai) + @ccall blasfeo.blasfeo_print_to_file_dvec(file::Ptr{Libc.FILE}, m::Cint, sa::Ptr{blasfeo_dvec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_to_file_tran_dvec(file, m, sa, ai) + +print to file the transposed of a strvec +""" +function blasfeo_print_to_file_tran_dvec(file, m, sa, ai) + @ccall blasfeo.blasfeo_print_to_file_tran_dvec(file::Ptr{Libc.FILE}, m::Cint, sa::Ptr{blasfeo_dvec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_to_string_dvec(buf_out, m, sa, ai) + +print to string a strvec +""" +function blasfeo_print_to_string_dvec(buf_out, m, sa, ai) + @ccall blasfeo.blasfeo_print_to_string_dvec(buf_out::Ptr{Ptr{Cchar}}, m::Cint, sa::Ptr{blasfeo_dvec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_to_string_dmat(buf_out, m, n, sA, ai, aj) + +print to string a strmat +""" +function blasfeo_print_to_string_dmat(buf_out, m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_to_string_dmat(buf_out::Ptr{Ptr{Cchar}}, m::Cint, n::Cint, sA::Ptr{blasfeo_dmat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_to_string_tran_dvec(buf_out, m, sa, ai) + +print to string the transposed of a strvec +""" +function blasfeo_print_to_string_tran_dvec(buf_out, m, sa, ai) + @ccall blasfeo.blasfeo_print_to_string_tran_dvec(buf_out::Ptr{Ptr{Cchar}}, m::Cint, sa::Ptr{blasfeo_dvec}, ai::Cint)::Cvoid +end + +""" + s_zeros(pA, row, col) + +dynamically allocate row*col floats of memory and set accordingly a pointer to float; set allocated memory to zero +""" +function s_zeros(pA, row, col) + @ccall blasfeo.s_zeros(pA::Ptr{Ptr{Cfloat}}, row::Cint, col::Cint)::Cvoid +end + +""" + s_zeros_align(pA, row, col) + +dynamically allocate row*col floats of memory aligned to 64-byte boundaries and set accordingly a pointer to float; set allocated memory to zero +""" +function s_zeros_align(pA, row, col) + @ccall blasfeo.s_zeros_align(pA::Ptr{Ptr{Cfloat}}, row::Cint, col::Cint)::Cvoid +end + +""" + s_zeros_align_bytes(pA, size) + +dynamically allocate size bytes of memory aligned to 64-byte boundaries and set accordingly a pointer to float; set allocated memory to zero +""" +function s_zeros_align_bytes(pA, size) + @ccall blasfeo.s_zeros_align_bytes(pA::Ptr{Ptr{Cfloat}}, size::Cint)::Cvoid +end + +""" + s_free(pA) + +free the memory allocated by d_zeros +""" +function s_free(pA) + @ccall blasfeo.s_free(pA::Ptr{Cfloat})::Cvoid +end + +""" + s_free_align(pA) + +free the memory allocated by d_zeros_align or d_zeros_align_bytes +""" +function s_free_align(pA) + @ccall blasfeo.s_free_align(pA::Ptr{Cfloat})::Cvoid +end + +""" + s_print_mat(m, n, A, lda) + +print a column-major matrix +""" +function s_print_mat(m, n, A, lda) + @ccall blasfeo.s_print_mat(m::Cint, n::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + s_print_exp_mat(m, n, A, lda) + +print in exponential notation a column-major matrix +""" +function s_print_exp_mat(m, n, A, lda) + @ccall blasfeo.s_print_exp_mat(m::Cint, n::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + s_print_tran_mat(row, col, A, lda) + +print the transposed of a column-major matrix +""" +function s_print_tran_mat(row, col, A, lda) + @ccall blasfeo.s_print_tran_mat(row::Cint, col::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + s_print_exp_tran_mat(row, col, A, lda) + +print in exponential notation the transposed of a column-major matrix +""" +function s_print_exp_tran_mat(row, col, A, lda) + @ccall blasfeo.s_print_exp_tran_mat(row::Cint, col::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + s_print_to_file_mat(file, row, col, A, lda) + +print to file a column-major matrix +""" +function s_print_to_file_mat(file, row, col, A, lda) + @ccall blasfeo.s_print_to_file_mat(file::Ptr{Libc.FILE}, row::Cint, col::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + s_print_to_file_exp_mat(file, row, col, A, lda) + +print to file a column-major matrix in exponential format +""" +function s_print_to_file_exp_mat(file, row, col, A, lda) + @ccall blasfeo.s_print_to_file_exp_mat(file::Ptr{Libc.FILE}, row::Cint, col::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + s_print_tran_to_file_mat(file, row, col, A, lda) + +print to file the transposed of a column-major matrix +""" +function s_print_tran_to_file_mat(file, row, col, A, lda) + @ccall blasfeo.s_print_tran_to_file_mat(file::Ptr{Libc.FILE}, row::Cint, col::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + s_print_tran_to_file_exp_mat(file, row, col, A, lda) + +print to file the transposed of a column-major matrix in exponential format +""" +function s_print_tran_to_file_exp_mat(file, row, col, A, lda) + @ccall blasfeo.s_print_tran_to_file_exp_mat(file::Ptr{Libc.FILE}, row::Cint, col::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + s_print_to_string_mat(buf_out, row, col, A, lda) + +print to string a column-major matrix +""" +function s_print_to_string_mat(buf_out, row, col, A, lda) + @ccall blasfeo.s_print_to_string_mat(buf_out::Ptr{Ptr{Cchar}}, row::Cint, col::Cint, A::Ptr{Cfloat}, lda::Cint)::Cvoid +end + +""" + blasfeo_allocate_smat(m, n, sA) + +create a strmat for a matrix of size m*n by dynamically allocating memory +""" +function blasfeo_allocate_smat(m, n, sA) + @ccall blasfeo.blasfeo_allocate_smat(m::Cint, n::Cint, sA::Ptr{blasfeo_smat})::Cvoid +end + +""" + blasfeo_allocate_svec(m, sa) + +create a strvec for a vector of size m by dynamically allocating memory +""" +function blasfeo_allocate_svec(m, sa) + @ccall blasfeo.blasfeo_allocate_svec(m::Cint, sa::Ptr{blasfeo_svec})::Cvoid +end + +""" + blasfeo_free_smat(sA) + +free the memory allocated by blasfeo_allocate_dmat +""" +function blasfeo_free_smat(sA) + @ccall blasfeo.blasfeo_free_smat(sA::Ptr{blasfeo_smat})::Cvoid +end + +""" + blasfeo_free_svec(sa) + +free the memory allocated by blasfeo_allocate_dvec +""" +function blasfeo_free_svec(sa) + @ccall blasfeo.blasfeo_free_svec(sa::Ptr{blasfeo_svec})::Cvoid +end + +""" + blasfeo_print_smat(m, n, sA, ai, aj) + +print a strmat +""" +function blasfeo_print_smat(m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_smat(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_exp_smat(m, n, sA, ai, aj) + +print in exponential notation a strmat +""" +function blasfeo_print_exp_smat(m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_exp_smat(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_tran_smat(m, n, sA, ai, aj) + +print the transpose of a strmat +""" +function blasfeo_print_tran_smat(m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_tran_smat(m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_svec(m, sa, ai) + +print a strvec +""" +function blasfeo_print_svec(m, sa, ai) + @ccall blasfeo.blasfeo_print_svec(m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_exp_svec(m, sa, ai) + +print in exponential notation a strvec +""" +function blasfeo_print_exp_svec(m, sa, ai) + @ccall blasfeo.blasfeo_print_exp_svec(m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_tran_svec(m, sa, ai) + +print the transposed of a strvec +""" +function blasfeo_print_tran_svec(m, sa, ai) + @ccall blasfeo.blasfeo_print_tran_svec(m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_exp_tran_svec(m, sa, ai) + +print in exponential notation the transposed of a strvec +""" +function blasfeo_print_exp_tran_svec(m, sa, ai) + @ccall blasfeo.blasfeo_print_exp_tran_svec(m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_to_file_smat(file, m, n, sA, ai, aj) + +print to file a strmat +""" +function blasfeo_print_to_file_smat(file, m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_to_file_smat(file::Ptr{Libc.FILE}, m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_to_file_exp_smat(file, m, n, sA, ai, aj) + +print to file a strmat in exponential format +""" +function blasfeo_print_to_file_exp_smat(file, m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_to_file_exp_smat(file::Ptr{Libc.FILE}, m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_to_file_svec(file, m, sa, ai) + +print to file a strvec +""" +function blasfeo_print_to_file_svec(file, m, sa, ai) + @ccall blasfeo.blasfeo_print_to_file_svec(file::Ptr{Libc.FILE}, m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_to_file_tran_svec(file, m, sa, ai) + +print to file the transposed of a strvec +""" +function blasfeo_print_to_file_tran_svec(file, m, sa, ai) + @ccall blasfeo.blasfeo_print_to_file_tran_svec(file::Ptr{Libc.FILE}, m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_to_string_smat(buf_out, m, n, sA, ai, aj) + +print to string a strmat +""" +function blasfeo_print_to_string_smat(buf_out, m, n, sA, ai, aj) + @ccall blasfeo.blasfeo_print_to_string_smat(buf_out::Ptr{Ptr{Cchar}}, m::Cint, n::Cint, sA::Ptr{blasfeo_smat}, ai::Cint, aj::Cint)::Cvoid +end + +""" + blasfeo_print_to_string_svec(buf_out, m, sa, ai) + +print to string a strvec +""" +function blasfeo_print_to_string_svec(buf_out, m, sa, ai) + @ccall blasfeo.blasfeo_print_to_string_svec(buf_out::Ptr{Ptr{Cchar}}, m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +""" + blasfeo_print_to_string_tran_svec(buf_out, m, sa, ai) + +print to string the transposed of a strvec +""" +function blasfeo_print_to_string_tran_svec(buf_out, m, sa, ai) + @ccall blasfeo.blasfeo_print_to_string_tran_svec(buf_out::Ptr{Ptr{Cchar}}, m::Cint, sa::Ptr{blasfeo_svec}, ai::Cint)::Cvoid +end + +const D_EL_SIZE = 8 + +const S_EL_SIZE = 4 + +const CACHE_LINE_SIZE = 64 + +const L1_CACHE_SIZE = 32 * 1024 + +const L2_CACHE_SIZE = 256 * 1024 + +const LLC_CACHE_SIZE = 6 * 1024 * 1024 + +const D_PS = 4 + +const D_PLD = 4 + +const D_M_KERNEL = 12 + +const D_N_KERNEL = 8 + +const D_KC = 256 + +const D_NC = 64 + +const D_MC = 1500 + +const S_PS = 8 + +const S_PLD = 4 + +const S_M_KERNEL = 24 + +const S_N_KERNEL = 8 + +const S_KC = 256 + +const S_NC = 144 + +const S_MC = 3000 + +const D_CACHE_LINE_EL = CACHE_LINE_SIZE ÷ D_EL_SIZE + +const D_L1_CACHE_EL = L1_CACHE_SIZE ÷ D_EL_SIZE + +const D_L2_CACHE_EL = L2_CACHE_SIZE ÷ D_EL_SIZE + +const D_LLC_CACHE_EL = LLC_CACHE_SIZE ÷ D_EL_SIZE + +const S_CACHE_LINE_EL = CACHE_LINE_SIZE ÷ S_EL_SIZE + +const S_L1_CACHE_EL = L1_CACHE_SIZE ÷ S_EL_SIZE + +const S_L2_CACHE_EL = L2_CACHE_SIZE ÷ S_EL_SIZE + +const S_LLC_CACHE_EL = LLC_CACHE_SIZE ÷ S_EL_SIZE + +# exports +const PREFIXES = ["blasfeo_"] +for name in names(@__MODULE__; all=true), prefix in PREFIXES + if startswith(string(name), prefix) + @eval export $name + end +end + +end # module diff --git a/src/mats.jl b/src/mats.jl index 126db22..9427651 100644 --- a/src/mats.jl +++ b/src/mats.jl @@ -6,36 +6,28 @@ # bits clone of panel major `blasfeo_dmat` # blasfeo_jll compiles with PANELMAJ so we only need this one and not the column major version mutable struct BlasfeoDmat <: AbstractMatrix{Cdouble} - const mem::Ptr{Cdouble} # pointer to passed chunk of memory - const pA::Ptr{Cdouble} # pointer to a pm*pn array of doubles, the first is aligned to cache line size - const dA::Ptr{Cdouble} # pointer to a min(m,n) (or max???) array of doubles - const m::Cint # rows - const n::Cint # cols - const pm::Cint # packed number or rows - const cn::Cint # packed number or cols - const use_dA::Cint # flag to tell if dA can be used - const memsize::Cint # size of needed memory + mat::Base.RefValue{blasfeo_dmat} function BlasfeoDmat(m::Integer,n::Integer) - mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) - @ccall blasfeo.blasfeo_allocate_dmat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoDmat})::Cvoid + blasfeo_mat = blasfeo_dmat(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + ptr_blasfeo_mat = Ref(blasfeo_mat) + blasfeo_allocate_dmat(m, n, ptr_blasfeo_mat) + mat = new(ptr_blasfeo_mat) function destructor(this) - @ccall blasfeo.blasfeo_free_dmat(pointer_from_objref(this)::Ptr{BlasfeoDmat})::Cvoid + blasfeo_free_dmat(this.mat) end return finalizer(destructor, mat) end function BlasfeoDmat(other::Matrix{Cdouble}) - mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + blasfeo_mat = blasfeo_dmat(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) m,n = size(other) - @ccall blasfeo.blasfeo_allocate_dmat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoDmat})::Cvoid + blasfeo_allocate_dmat(m, n, blasfeo_mat) + mat = new(blasfeo_mat) function destructor(this) - @ccall blasfeo.blasfeo_free_dmat(pointer_from_objref(this)::Ptr{BlasfeoDmat})::Cvoid + blasfeo_free_dmat(this.mat) end - @ccall blasfeo.blasfeo_pack_dmat(m::Cint, n::Cint, - other::Ptr{Cdouble}, m::Cint, - pointer_from_objref(mat)::Ptr{BlasfeoDmat}, - 0::Cint, 0::Cint)::Cvoid + blasfeo_pack_dmat(m, n, other, m, blasfeo_mat, 0, 0)::Cvoid return finalizer(destructor, mat) end end @@ -43,36 +35,27 @@ end # bits clone of panel major `blasfeo_smat` # blasfeo_jll compiles with PANELMAJ so we only need this one and not the column major version mutable struct BlasfeoSmat <: AbstractMatrix{Cfloat} - const mem::Ptr{Cfloat} # pointer to passed chunk of memory - const pA::Ptr{Cfloat} # pointer to a pm*pn array of doubles, the first is aligned to cache line size - const dA::Ptr{Cfloat} # pointer to a min(m,n) (or max???) array of doubles - const m::Cint # rows - const n::Cint # cols - const pm::Cint # packed number or rows - const cn::Cint # packed number or cols - const use_dA::Cint # flag to tell if dA can be used - const memsize::Cint # size of needed memory + mat::blasfeo_dmat function BlasfeoSmat(m::Integer,n::Integer) - mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) - @ccall blasfeo.blasfeo_allocate_smat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoSmat})::Cvoid + blasfeo_mat = blasfeo_smat(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + blasfeo_allocate_smat(m, n, blasfeo_mat) + mat = new(blasfeo_mat) function destructor(this) - @ccall blasfeo.blasfeo_free_smat(pointer_from_objref(this)::Ptr{BlasfeoSmat})::Cvoid + blasfeo_free_smat(this.mat) end return finalizer(destructor, mat) end function BlasfeoSmat(other::Matrix{Cfloat}) - mat = new(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + blasfeo_mat = blasfeo_smat(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) m,n = size(other) - @ccall blasfeo.blasfeo_allocate_smat(m::Cint, n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoSmat})::Cvoid + blasfeo_allocate_smat(m, n, blasfeo_mat) + mat = new(blasfeo_mat) function destructor(this) - @ccall blasfeo.blasfeo_free_smat(pointer_from_objref(this)::Ptr{BlasfeoSmat})::Cvoid + blasfeo_free_smat(this.mat) end - @ccall blasfeo.blasfeo_pack_smat(m::Cint, n::Cint, - other::Ptr{Cdouble}, m::Cint, - pointer_from_objref(mat)::Ptr{BlasfeoSmat}, - 0::Cint, 0::Cint)::Cvoid + blasfeo_pack_smat(m, n, other, m, blasfeo_mat, 0, 0)::Cvoid return finalizer(destructor, mat) end end @@ -83,15 +66,15 @@ for (type,flag) in [ (:BlasfeoSmat, :s), ] # size - @eval Base.size(A::$type) = (A.m, A.n) + @eval Base.size(A::$type) = (A.mat[].m, A.mat[].n) # getindex blasfeo_geex1 = Symbol(:blasfeo_, flag, :geex1) - @eval Base.getindex(A::$type, I::Vararg{Int, 2}) = @ccall blasfeo.$blasfeo_geex1(pointer_from_objref(A)::Ptr{$type}, (I[1]-1)::Cint, (I[2]-1)::Cint)::eltype($type) + @eval Base.getindex(A::$type, I::Vararg{Int, 2}) = $blasfeo_geex1(A.mat, I[1]-1, I[2]-1) # setindex! blasfeo_gein1 = Symbol(:blasfeo_, flag, :gein1) - @eval Base.setindex!(A::$type, v::T, I::Vararg{Int, 2}) where {T <: Real} = @ccall blasfeo.$blasfeo_gein1(v::eltype($type),pointer_from_objref(A)::Ptr{$type}, (I[1]-1)::Cint, (I[2]-1)::Cint)::eltype($type) + @eval Base.setindex!(A::$type, v::T, I::Vararg{Int, 2}) where {T <: Real} = $blasfeo_gein1(v, A.mat, I[1]-1, I[2]-1) # similar @eval Base.similar(A::$type) = $type(A.m, A.n) @@ -101,25 +84,22 @@ for (type,flag) in [ blasfeo_gecp = Symbol(:blasfeo_, flag, :gecp) @eval function Base.copy(A::$type) B = similar(A) - A_ptr = pointer_from_objref(A) - B_ptr = pointer_from_objref(B) - @ccall blasfeo.$blasfeo_gecp( - A.m::Cint, A.n::Cint, - A_ptr::Ptr{$type}, 0::Cint, 0::Cint, - B_ptr::Ptr{$type}, 0::Cint, 0::Cint - )::Cvoid + $blasfeo_gecp( + size(A,1), size(A,2), + A.mat, 0, 0, + B.mat, 0, 0, + ) return B end # fill! blasfeo_gese = Symbol(:blasfeo_, flag, :gese) @eval function Base.fill!(A::$type, b::T) where {T <: Real} - A_ptr = pointer_from_objref(A) - @ccall blasfeo.$blasfeo_gese( - A.m::Cint, A.n::Cint, - b::eltype($type), - A_ptr::Ptr{$type}, 0::Cint, 0::Cint, - )::Cvoid + $blasfeo_gese( + size(A,1), size(A,2), + b, + A.mat, 0, 0, + ) return A end @@ -128,26 +108,20 @@ for (type,flag) in [ blasfeo_unpack = Symbol(:blasfeo_unpack_, flag, :mat) blasfeo_pack = Symbol(:blasfeo_pack_, flag, :mat) @eval function Base.convert(::Type{Matrix{eltype($type)}}, A::$type) - A_ptr = pointer_from_objref(A) B = Matrix{eltype($type)}(undef, size(A)) - @ccall blasfeo.$blasfeo_unpack( - A.m::Cint, A.n::Cint, - A_ptr::Ptr{$type}, - 0::Cint, 0::Cint, - B::Ptr{eltype($type)}, - A.m::Cint + $blasfeo_unpack( + size(A,1), size(A,2), + A.mat, 0, 0, + B, stride(B), )::Cvoid return B end @eval function Base.convert(::Type{$type}, A::Matrix{eltype($type)}) B = $type(size(A)...) - B_ptr = pointer_from_objref(B) - m,n = size(A) - @ccall blasfeo.$blasfeo_pack( - m::Cint, n::Cint, - A::Ptr{eltype($type)}, m::Cint, - B_ptr::Ptr{$type}, - 0::Cint, 0::Cint + $blasfeo_pack( + size(A,1), size(A,2), + A, stride(A), + B.mat, 0, 0, )::Cvoid return B end diff --git a/src/show.jl b/src/show.jl index add7b1f..08b63ce 100644 --- a/src/show.jl +++ b/src/show.jl @@ -1,13 +1,19 @@ # TODO(@anton) mxn or nxm -function Base.show(io, mat::BlasfeoDmat) - println("$(mat.m)x$(mat.n) BlasfeoDmat:") - @ccall blasfeo.blasfeo_print_dmat(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoDmat}, 0::Cint, 0::Cint)::Cvoid +function Base.show(io, A::BlasfeoDmat) + println("$(size(A,1))x$(size(A,2)) BlasfeoDmat:") + blasfeo_print_dmat( + size(A,1), size(A,2), + A.mat, 0, 0, + ) end -function Base.show(io, mat::BlasfeoSmat) - println("$(mat.m)x$(mat.n) BlasfeoSmat:") - @ccall blasfeo.blasfeo_print_smat(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{BlasfeoSmat}, 0::Cint, 0::Cint)::Cvoid +function Base.show(io, A::BlasfeoSmat) + println("$(size(A,1))x$(size(A,2)) BlasfeoSmat:") + blasfeo_print_smat( + size(A,1), size(A,2), + A.mat, 0, 0, + ) end function Base.show(io, vec::BlasfeoDvec) @@ -43,16 +49,22 @@ for (type,shortname) in [ (:BlasfeoDmat, "dmat"), (:BlasfeoSmat, "smat"), ] - printer = Symbol(:blasfeo_print_,shortname) + blasfeo_print_mat = Symbol(:blasfeo_print_,shortname) @eval begin - function Base.show(io::IO, ::MIME"text/plain", mat::$type) - println("$(mat.m)x$(mat.n) $($type):") - @ccall blasfeo.$printer(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{$type}, 0::Cint, 0::Cint)::Cvoid + function Base.show(io::IO, ::MIME"text/plain", A::$type) + println("$(size(A,1))x$(size(A,2)) $($type):") + $blasfeo_print_mat( + size(A,1), size(A,2), + A.mat, 0, 0, + ) end - function Base.show(io::IO, mat::$type) - println("$(mat.m)x$(mat.n) $($type):") - @ccall blasfeo.$printer(mat.m::Cint, mat.n::Cint, pointer_from_objref(mat)::Ptr{$type}, 0::Cint, 0::Cint)::Cvoid + function Base.show(io::IO, A::$type) + println("$(size(A,1))x$(size(A,2)) $($type):") + $blasfeo_print_mat( + size(A,1), size(A,2), + A.mat, 0, 0, + ) end end end From 61614be4cdf77a1f2c79731e68ec22f00e74f12f Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 11:22:54 +0200 Subject: [PATCH 06/20] update high level mats.jl, add unsafe_convert so you can fall back to the c interface --- src/mats.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mats.jl b/src/mats.jl index 9427651..d12c5e1 100644 --- a/src/mats.jl +++ b/src/mats.jl @@ -125,4 +125,8 @@ for (type,flag) in [ )::Cvoid return B end + + # unsafe_convert to Ptr{blasfeo_[ds]mat} so you can directly pass to the low level c_interface + blasfeo_mat = Symbol(:blasfeo_, flag, :mat) + @eval Base.unsafe_convert(::Type{Ptr{$blasfeo_mat}}, A::$type) = Base.unsafe_convert(Ptr{$blasfeo_mat}, A.mat) end From 915e1156d0d036eef9e5aa78b506fc35ddc323a4 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 11:47:41 +0200 Subject: [PATCH 07/20] fix typos in mats.jl, add support for LibBlasfeo based Dvec and Svec --- src/mats.jl | 51 +++++++++++++------------- src/show.jl | 14 ++++---- src/vecs.jl | 102 ++++++++++++++++++++++++++-------------------------- 3 files changed, 85 insertions(+), 82 deletions(-) diff --git a/src/mats.jl b/src/mats.jl index d12c5e1..9694179 100644 --- a/src/mats.jl +++ b/src/mats.jl @@ -10,24 +10,25 @@ mutable struct BlasfeoDmat <: AbstractMatrix{Cdouble} function BlasfeoDmat(m::Integer,n::Integer) blasfeo_mat = blasfeo_dmat(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) - ptr_blasfeo_mat = Ref(blasfeo_mat) - blasfeo_allocate_dmat(m, n, ptr_blasfeo_mat) - mat = new(ptr_blasfeo_mat) + ref_blasfeo_mat = Ref(blasfeo_mat) + blasfeo_allocate_dmat(m, n, ref_blasfeo_mat) + mat = new(ref_blasfeo_mat) function destructor(this) - blasfeo_free_dmat(this.mat) + blasfeo_free_dmat(this) end return finalizer(destructor, mat) end function BlasfeoDmat(other::Matrix{Cdouble}) blasfeo_mat = blasfeo_dmat(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + ref_blasfeo_mat = Ref(blasfeo_mat) m,n = size(other) - blasfeo_allocate_dmat(m, n, blasfeo_mat) - mat = new(blasfeo_mat) + blasfeo_allocate_dmat(m, n, ref_blasfeo_mat) + mat = new(ref_blasfeo_mat) function destructor(this) - blasfeo_free_dmat(this.mat) + blasfeo_free_dmat(this) end - blasfeo_pack_dmat(m, n, other, m, blasfeo_mat, 0, 0)::Cvoid + blasfeo_pack_dmat(m, n, other, m, mat, 0, 0) return finalizer(destructor, mat) end end @@ -35,27 +36,29 @@ end # bits clone of panel major `blasfeo_smat` # blasfeo_jll compiles with PANELMAJ so we only need this one and not the column major version mutable struct BlasfeoSmat <: AbstractMatrix{Cfloat} - mat::blasfeo_dmat + mat::Base.RefValue{blasfeo_smat} function BlasfeoSmat(m::Integer,n::Integer) blasfeo_mat = blasfeo_smat(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) - blasfeo_allocate_smat(m, n, blasfeo_mat) - mat = new(blasfeo_mat) + ref_blasfeo_mat = Ref(blasfeo_mat) + blasfeo_allocate_smat(m, n, ref_blasfeo_mat) + mat = new(ref_blasfeo_mat) function destructor(this) - blasfeo_free_smat(this.mat) + blasfeo_free_smat(this) end return finalizer(destructor, mat) end function BlasfeoSmat(other::Matrix{Cfloat}) blasfeo_mat = blasfeo_smat(C_NULL,C_NULL,C_NULL,0,0,0,0,0,0) + ref_blasfeo_mat = Ref(blasfeo_mat) m,n = size(other) - blasfeo_allocate_smat(m, n, blasfeo_mat) - mat = new(blasfeo_mat) + blasfeo_allocate_smat(m, n, ref_blasfeo_mat) + mat = new(ref_blasfeo_mat) function destructor(this) - blasfeo_free_smat(this.mat) + blasfeo_free_smat(this) end - blasfeo_pack_smat(m, n, other, m, blasfeo_mat, 0, 0)::Cvoid + blasfeo_pack_smat(m, n, other, m, mat, 0, 0) return finalizer(destructor, mat) end end @@ -70,14 +73,14 @@ for (type,flag) in [ # getindex blasfeo_geex1 = Symbol(:blasfeo_, flag, :geex1) - @eval Base.getindex(A::$type, I::Vararg{Int, 2}) = $blasfeo_geex1(A.mat, I[1]-1, I[2]-1) + @eval Base.getindex(A::$type, I::Vararg{Int, 2}) = $blasfeo_geex1(A, I[1]-1, I[2]-1) # setindex! blasfeo_gein1 = Symbol(:blasfeo_, flag, :gein1) - @eval Base.setindex!(A::$type, v::T, I::Vararg{Int, 2}) where {T <: Real} = $blasfeo_gein1(v, A.mat, I[1]-1, I[2]-1) + @eval Base.setindex!(A::$type, v::T, I::Vararg{Int, 2}) where {T <: Real} = $blasfeo_gein1(v, A, I[1]-1, I[2]-1) # similar - @eval Base.similar(A::$type) = $type(A.m, A.n) + @eval Base.similar(A::$type) = $type(size(A)...) @eval Base.similar(A::$type,dims::Dims{2}) = $type(dims...) # copy @@ -86,8 +89,8 @@ for (type,flag) in [ B = similar(A) $blasfeo_gecp( size(A,1), size(A,2), - A.mat, 0, 0, - B.mat, 0, 0, + A, 0, 0, + B, 0, 0, ) return B end @@ -98,7 +101,7 @@ for (type,flag) in [ $blasfeo_gese( size(A,1), size(A,2), b, - A.mat, 0, 0, + A, 0, 0, ) return A end @@ -111,7 +114,7 @@ for (type,flag) in [ B = Matrix{eltype($type)}(undef, size(A)) $blasfeo_unpack( size(A,1), size(A,2), - A.mat, 0, 0, + A, 0, 0, B, stride(B), )::Cvoid return B @@ -121,7 +124,7 @@ for (type,flag) in [ $blasfeo_pack( size(A,1), size(A,2), A, stride(A), - B.mat, 0, 0, + B, 0, 0, )::Cvoid return B end diff --git a/src/show.jl b/src/show.jl index 08b63ce..199c688 100644 --- a/src/show.jl +++ b/src/show.jl @@ -31,23 +31,23 @@ for (type,shortname) in [ (:BlasfeoDvec, :dvec), (:BlasfeoSvec, :svec), ] - printer = Symbol(:blasfeo_print_,shortname) + blasfeo_print_vec = Symbol(:blasfeo_print_,shortname) @eval begin function Base.show(io::IO, ::MIME"text/plain", vec::$type) - println("$(vec.m)-element $($type):") - @ccall blasfeo.$printer(vec.m::Cint, pointer_from_objref(vec)::Ptr{$type}, 0::Cint)::Cvoid + println("$(length(vec))-element $($type):") + $blasfeo_print_vec(length(vec), vec, 0) end function Base.show(io::IO, vec::$type) - println("$(vec.m)-element $($type):") - @ccall blasfeo.$printer(vec.m::Cint, pointer_from_objref(vec)::Ptr{$type}, 0::Cint)::Cvoid + println("$(length(vec))-element $($type):") + $blasfeo_print_vec(length(vec), vec, 0) end end end for (type,shortname) in [ - (:BlasfeoDmat, "dmat"), - (:BlasfeoSmat, "smat"), + (:BlasfeoDmat, :dmat), + (:BlasfeoSmat, :smat), ] blasfeo_print_mat = Symbol(:blasfeo_print_,shortname) @eval begin diff --git a/src/vecs.jl b/src/vecs.jl index 509809e..3fa57ad 100644 --- a/src/vecs.jl +++ b/src/vecs.jl @@ -5,66 +5,58 @@ # bits clone of panel major `blasfeo_dvec` mutable struct BlasfeoDvec <: AbstractVector{Cdouble} - mem::Ptr{Cdouble} # pointer to passed chunk of memory - pa::Ptr{Cdouble} # pointer to a pm array of doubles, the first is aligned to cache line size - m::Cint # size - pm::Cint # packed size - memsize::Cint # size of needed memory + vec::Base.RefValue{blasfeo_dvec} function BlasfeoDvec(m::T) where {T <: Integer} - vec = new(C_NULL,C_NULL,0,0,0) - @ccall blasfeo.blasfeo_allocate_dvec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec})::Cvoid + blasfeo_vec = blasfeo_dvec(C_NULL,C_NULL,0,0,0) + ref_blasfeo_vec = Ref(blasfeo_vec) + blasfeo_allocate_dvec(m, ref_blasfeo_vec) + vec = new(ref_blasfeo_vec) function destructor(this) - @ccall blasfeo.blasfeo_free_dvec(pointer_from_objref(this)::Ptr{BlasfeoDvec})::Cvoid + blasfeo_free_dvec(this) end return finalizer(destructor, vec) end function BlasfeoDvec(other::Vector{Cdouble}) - vec = new(C_NULL,C_NULL,0,0,0) - @ccall blasfeo.blasfeo_allocate_dvec(length(other)::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec})::Cvoid + blasfeo_vec = blasfeo_dvec(C_NULL,C_NULL,0,0,0) + ref_blasfeo_vec = Ref(blasfeo_vec) + m = length(other) + blasfeo_allocate_dvec(m, ref_blasfeo_vec) + vec = new(ref_blasfeo_vec) function destructor(this) - @ccall blasfeo.blasfeo_free_dvec(pointer_from_objref(this)::Ptr{BlasfeoDvec})::Cvoid + blasfeo_free_dvec(this) end - - @ccall blasfeo.blasfeo_pack_dvec(vec.m::Cint, - other::Ptr{Cdouble}, 1::Cint, - pointer_from_objref(vec)::Ptr{BlasfeoDvec}, - 0::Cint)::Cvoid - + blasfeo_pack_dvec(m, other, 1, vec, 0)::Cvoid return finalizer(destructor, vec) end end # bits clone of panel major `blasfeo_svec` mutable struct BlasfeoSvec <: AbstractVector{Cfloat} - mem::Ptr{Cfloat} # pointer to passed chunk of memory - pa::Ptr{Cfloat} # pointer to a pm array of floats, the first is aligned to cache line size - m::Cint # size - pm::Cint # packed size - memsize::Cint # size of needed memory + vec::Base.RefValue{blasfeo_svec} function BlasfeoSvec(m::T) where {T <: Integer} - vec = new(C_NULL,C_NULL,0,0,0) - @ccall blasfeo.blasfeo_allocate_svec(m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec})::Cvoid + blasfeo_vec = blasfeo_svec(C_NULL,C_NULL,0,0,0) + ref_blasfeo_vec = Ref(blasfeo_vec) + blasfeo_allocate_svec(m, ref_blasfeo_vec) + vec = new(ref_blasfeo_vec) function destructor(this) - @ccall blasfeo.blasfeo_free_svec(pointer_from_objref(this)::Ptr{BlasfeoSvec})::Cvoid + blasfeo_free_svec(this) end return finalizer(destructor, vec) end function BlasfeoSvec(other::Vector{Cfloat}) - vec = new(C_NULL,C_NULL,0,0,0) - @ccall blasfeo.blasfeo_allocate_svec(length(other)::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec})::Cvoid + blasfeo_vec = blasfeo_svec(C_NULL,C_NULL,0,0,0) + ref_blasfeo_vec = Ref(blasfeo_vec) + m = length(other) + blasfeo_allocate_svec(m, ref_blasfeo_vec) + vec = new(ref_blasfeo_vec) function destructor(this) - @ccall blasfeo.blasfeo_free_svec(pointer_from_objref(this)::Ptr{BlasfeoSvec})::Cvoid + blasfeo_free_svec(this) end - - @ccall blasfeo.blasfeo_pack_svec(vec.m::Cint, - other::Ptr{Cfloat}, 1::Cint, - pointer_from_objref(vec)::Ptr{BlasfeoSvec}, - 0::Cint)::Cvoid - + blasfeo_pack_svec(m, other, 1, vec, 0) return finalizer(destructor, vec) end end @@ -75,43 +67,51 @@ for (type,flag) in [ (:BlasfeoSvec, :s), ] # size - @eval Base.size(A::$type) = (A.m,) + @eval Base.size(A::$type) = (A.vec[].m,) # getindex blasfeo_vecex1 = Symbol(:blasfeo_, flag, :vecex1) - @eval Base.getindex(A::$type, I::Vararg{Int, 1}) = @ccall blasfeo.$blasfeo_vecex1(pointer_from_objref(A)::Ptr{$type}, (I[1]-1)::Cint)::eltype($type) + @eval Base.getindex(A::$type, I::Vararg{Int, 1}) = $blasfeo_vecex1(A, I[1]-1) # setindex! blasfeo_vecin1 = Symbol(:blasfeo_, flag, :vecin1) - @eval Base.setindex!(A::$type, v::T, I::Vararg{Int, 1}) where {T <: Real} = @ccall blasfeo.$blasfeo_vecin1(v::eltype($type),pointer_from_objref(A)::Ptr{$type}, (I[1]-1)::Cint)::eltype($type) + @eval Base.setindex!(A::$type, v::T, I::Vararg{Int, 1}) where {T <: Real} = $blasfeo_vecin1(v, A, I[1]-1) # similar - @eval Base.similar(A::$type) = $type(A.m) + @eval Base.similar(A::$type) = $type(length(A)) @eval Base.similar(A::$type,dims::Dims{1}) = $type(dims...) # copy blasfeo_veccp = Symbol(:blasfeo_, flag, :veccp) @eval function Base.copy(A::$type) B = similar(A) - A_ptr = pointer_from_objref(A) - B_ptr = pointer_from_objref(B) - @ccall blasfeo.$blasfeo_veccp( - A.m::Cint, - A_ptr::Ptr{$type}, 0::Cint, - B_ptr::Ptr{$type}, 0::Cint, - )::Cvoid + $blasfeo_veccp(length(A), A, 0, B, 0) return B end # fill! blasfeo_vecse = Symbol(:blasfeo_, flag, :vecse) @eval function Base.fill!(A::$type, b::T) where {T <: Real} - A_ptr = pointer_from_objref(A) - @ccall blasfeo.$blasfeo_vecse( - A.m::Cint, - b::eltype($type), - A_ptr::Ptr{$type}, 0::Cint, - )::Cvoid + $blasfeo_vecse(length(A), b, A, 0) return A end + + # convert to Vector and back + # TODO(@anton) maybe the performance overhead of this means maybe we want only explicit constructors? + blasfeo_unpack = Symbol(:blasfeo_unpack_, flag, :vec) + blasfeo_pack = Symbol(:blasfeo_pack_, flag, :vec) + @eval function Base.convert(::Type{Vector{eltype($type)}}, A::$type) + B = Vector{eltype($type)}(undef, length(A)) + $blasfeo_unpack(length(A), A, 0, B, 1) + return B + end + @eval function Base.convert(::Type{$type}, A::Vector{eltype($type)}) + B = $type(length(A)) + $blasfeo_pack(length(A), A, 1, B, 0) + return B + end + + # unsafe_convert to Ptr{blasfeo_[ds]mat} so you can directly pass to the low level c_interface + blasfeo_vec = Symbol(:blasfeo_, flag, :vec) + @eval Base.unsafe_convert(::Type{Ptr{$blasfeo_vec}}, A::$type) = Base.unsafe_convert(Ptr{$blasfeo_vec}, A.vec) end From 5d6ba32df01547c6b3fee59c5fa2a4bfe657090e Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 12:53:29 +0200 Subject: [PATCH 08/20] vector tests --- src/level1.jl | 70 +++++++++++++++++----------------------------- src/mats.jl | 2 +- src/vecs.jl | 2 +- test/runtests.jl | 2 ++ test/vec/basics.jl | 34 +++++++++++----------- test/vec/level1.jl | 24 ++++++++++++++++ 6 files changed, 70 insertions(+), 64 deletions(-) create mode 100644 test/vec/level1.jl diff --git a/src/level1.jl b/src/level1.jl index a9fc235..a13c734 100644 --- a/src/level1.jl +++ b/src/level1.jl @@ -4,53 +4,39 @@ for (type,flag) in [ ] # dot blasfeo_dot = Symbol(:blasfeo_, flag, :dot) - @eval function LinearAlgebra.dot(a::$type, b::$type) - a_ptr=pointer_from_objref(a) - b_ptr=pointer_from_objref(b) - @ccall blasfeo.$blasfeo_dot( - a.m::Cint, a_ptr::Ptr{$type}, 0::Cint, - b_ptr::Ptr{$type}, 0::Cint, - )::eltype($type) - end + @eval LinearAlgebra.dot(a::$type, b::$type) = $blasfeo_dot(length(a), a, 0, b, 0) # axpy! blasfeo_axpy = Symbol(:blasfeo_, flag, :axpy) @eval function LinearAlgebra.axpy!(α::T, x::$type, y::$type) where {T <: Real} - x_ptr=pointer_from_objref(x) - y_ptr=pointer_from_objref(y) - @ccall blasfeo.$blasfeo_axpy( - x.m::Cint, - α::Cdouble, x_ptr::Ptr{$type}, 0::Cint, - y_ptr::Ptr{$type}, 0::Cint, - y_ptr::Ptr{$type}, 0::Cint, - )::Cvoid + $blasfeo_axpy( + length(x), + α, x, 0, + y, 0, + y, 0, + ) return y end - # 3 arg axpby + # 3 arg axpy @eval function axpy(α::T, x::$type, y::$type, z::$type) where {T <: Real} - x_ptr=pointer_from_objref(x) - y_ptr=pointer_from_objref(y) - z_ptr=pointer_from_objref(z) - @ccall blasfeo.$blasfeo_axpy( - x.m::Cint, - α::Cdouble, x_ptr::Ptr{$type}, 0::Cint, - y_ptr::Ptr{$type}, 0::Cint, - z_ptr::Ptr{$type}, 0::Cint, - )::Cvoid + $blasfeo_axpy( + length(x), + α, x, 0, + y, 0, + z, 0, + ) return z end - # axpby + # axpby! blasfeo_axpby = Symbol(:blasfeo_, flag, :axpby) @eval function LinearAlgebra.axpby!(α::T1, x::$type, β::T2, y::$type) where {T1 <: Real, T2 <: Real} - x_ptr=pointer_from_objref(x) - y_ptr=pointer_from_objref(y) - @ccall blasfeo.$blasfeo_axpby( - a.m::Cint, - α::Cdouble, x_ptr::Ptr{$type}, 0::Cint, - β::Cdouble, y_ptr::Ptr{$type}, 0::Cint, - y_ptr::Ptr{$type}, 0::Cint, + $blasfeo_axpby( + length(x), + α, x, 0, + β, y, 0, + y, 0, )::Cvoid return y end @@ -58,18 +44,12 @@ for (type,flag) in [ # 3 arg axpby blasfeo_axpby = Symbol(:blasfeo_, flag, :axpby) @eval function axpby(α::T1, x::$type, β::T2, y::$type, z::$type) where {T1 <: Real, T2 <: Real} - x_ptr=pointer_from_objref(x) - y_ptr=pointer_from_objref(y) - z_ptr=pointer_from_objref(z) - @ccall blasfeo.$blasfeo_axpby( - x.m::Cint, - α::Cdouble, x_ptr::Ptr{$type}, 0::Cint, - β::Cdouble, y_ptr::Ptr{$type}, 0::Cint, - z_ptr::Ptr{$type}, 0::Cint, + $blasfeo_axpby( + length(x), + α, x, 0, + β, y, 0, + z, 0, )::Cvoid return z end - - # :* - #@eval function Base.:* end diff --git a/src/mats.jl b/src/mats.jl index 9694179..7dc122c 100644 --- a/src/mats.jl +++ b/src/mats.jl @@ -129,7 +129,7 @@ for (type,flag) in [ return B end - # unsafe_convert to Ptr{blasfeo_[ds]mat} so you can directly pass to the low level c_interface + # unsafe_convert to Ptr{blasfeo_[ds]mat} so you can directly pass to the low level c interface blasfeo_mat = Symbol(:blasfeo_, flag, :mat) @eval Base.unsafe_convert(::Type{Ptr{$blasfeo_mat}}, A::$type) = Base.unsafe_convert(Ptr{$blasfeo_mat}, A.mat) end diff --git a/src/vecs.jl b/src/vecs.jl index 3fa57ad..e5236bb 100644 --- a/src/vecs.jl +++ b/src/vecs.jl @@ -111,7 +111,7 @@ for (type,flag) in [ return B end - # unsafe_convert to Ptr{blasfeo_[ds]mat} so you can directly pass to the low level c_interface + # unsafe_convert to Ptr{blasfeo_[ds]vec} so you can directly pass to the low level c interface blasfeo_vec = Symbol(:blasfeo_, flag, :vec) @eval Base.unsafe_convert(::Type{Ptr{$blasfeo_vec}}, A::$type) = Base.unsafe_convert(Ptr{$blasfeo_vec}, A.vec) end diff --git a/test/runtests.jl b/test/runtests.jl index 63df0b2..a473762 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,7 @@ using BLASFEO +using LinearAlgebra using Test include("mat/basics.jl") include("vec/basics.jl") +include("vec/level1.jl") diff --git a/test/vec/basics.jl b/test/vec/basics.jl index 90084ee..d302af9 100644 --- a/test/vec/basics.jl +++ b/test/vec/basics.jl @@ -1,27 +1,27 @@ @testset "Vector Basic Operations" begin @testset for VEC in (BlasfeoDvec, BlasfeoSvec) - A = rand(eltype(VEC), 100) - A_blasfeo = VEC(A) - @test A == A_blasfeo - @test A[10] == A_blasfeo[10] + a = rand(eltype(VEC), 100) + a_blasfeo = VEC(a) + @test a == a_blasfeo + @test a[10] == a_blasfeo[10] - A[10] = 10.0; A_blasfeo[10] = 10.0 - A[20] = 20; A_blasfeo[20] = 20 - @test A == A_blasfeo + a[10] = 10.0; a_blasfeo[10] = 10.0 + a[20] = 20; a_blasfeo[20] = 20 + @test a == a_blasfeo - B_blasfeo = similar(A_blasfeo) - @test size(A_blasfeo) == size(B_blasfeo) + b_blasfeo = similar(a_blasfeo) + @test size(a_blasfeo) == size(b_blasfeo) # Note(@anton) Blasfeo _always_ clears memory. - @test A_blasfeo != B_blasfeo + @test a_blasfeo != b_blasfeo - C_blasfeo = copy(A_blasfeo) - @test A_blasfeo == C_blasfeo + c_blasfeo = copy(a_blasfeo) + @test a_blasfeo == c_blasfeo - C_blasfeo[15] = 15.0 - @test C_blasfeo[15] == 15.0 - @test A_blasfeo != C_blasfeo + c_blasfeo[15] = 15.0 + @test c_blasfeo[15] == 15.0 + @test a_blasfeo != c_blasfeo - fill!(C_blasfeo, 100.0) - @test all(C_blasfeo .== 100.0) + fill!(c_blasfeo, 100.0) + @test all(c_blasfeo .== 100.0) end end diff --git a/test/vec/level1.jl b/test/vec/level1.jl new file mode 100644 index 0000000..f521128 --- /dev/null +++ b/test/vec/level1.jl @@ -0,0 +1,24 @@ +@testset "Level 1 BLAS Operations" begin + @testset for VEC in (BlasfeoDvec, BlasfeoSvec) + a = rand(eltype(VEC), 100) + b = rand(eltype(VEC), 100) + c = zeros(eltype(VEC), 100) + a_blasfeo = VEC(a) + b_blasfeo = VEC(b) + c_blasfeo = VEC(c) + + α = rand() + β = rand() + + # Test nondestructively + @test dot(a,b) ≈ dot(a_blasfeo, b_blasfeo) + @test (α.*a .+ b) ≈ axpy(α,a_blasfeo,b_blasfeo,c_blasfeo) + @test ((α.*a) .+ (β.*b)) ≈ axpby(α,a_blasfeo,β,b_blasfeo,c_blasfeo) + + # Test destructively + axpy!(α,a,b);axpy!(α,a_blasfeo,b_blasfeo) + @test b ≈ b_blasfeo + axpby!(α,a,β,b);axpby!(α,a_blasfeo,β,b_blasfeo) + @test b ≈ b_blasfeo + end +end From e3e1d484131ef3f03bdb561ccaed76e31553f4d2 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 13:12:36 +0200 Subject: [PATCH 09/20] update to supporting only LTS --- Project.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 83d8561..0663601 100644 --- a/Project.toml +++ b/Project.toml @@ -9,9 +9,8 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" blasfeo_jll = "6b574d4a-bb57-5a4b-b7e6-1c794c903646" [compat] -CEnum = "0.5.0" -LinearAlgebra = "1.12.0" -julia = "1" +blasfeo_jll = "0.1.3" +julia = "1.10" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" From 59b85e1b313198ec8090e6e2675980096e55bf83 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 13:15:26 +0200 Subject: [PATCH 10/20] update jll version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 0663601..194a8ad 100644 --- a/Project.toml +++ b/Project.toml @@ -9,7 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" blasfeo_jll = "6b574d4a-bb57-5a4b-b7e6-1c794c903646" [compat] -blasfeo_jll = "0.1.3" +blasfeo_jll = "0.1.4" julia = "1.10" [extras] From 7c55be3c99ac397256285c30ac9fd65359d12824 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 14:15:45 +0200 Subject: [PATCH 11/20] migrate to github actions :) --- .appveyor.yml | 28 ------------------- .github/dependabot.yml | 7 +++++ .github/workflows/CI.yml | 44 ++++++++++++++++++++++++++++++ .github/workflows/CompatHelper.yml | 18 ++++++++++++ .github/workflows/TagBot.yml | 19 +++++++++++++ .travis.yml | 27 ------------------ Project.toml | 2 +- docs/make.jl | 10 +++++-- 8 files changed, 97 insertions(+), 58 deletions(-) delete mode 100644 .appveyor.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/CI.yml create mode 100644 .github/workflows/CompatHelper.yml create mode 100644 .github/workflows/TagBot.yml delete mode 100644 .travis.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index a8cbdc3..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Documentation: https://github.com/JuliaCI/Appveyor.jl -environment: - matrix: - - julia_version: 1.0 - - julia_version: nightly -platform: - - x86 - - x64 -matrix: - allow_failures: - - julia_version: nightly -branches: - only: - - master - - /release-.*/ -notifications: - - provider: Email - on_build_success: false - on_build_failure: false - on_build_status_changed: false -install: - - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) -build_script: - - echo "%JL_BUILD_SCRIPT%" - - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" -test_script: - - echo "%JL_TEST_SCRIPT%" - - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..700707c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..811ee26 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,44 @@ +name: CI +on: + push: + branches: + - master + tags: ['*'] + pull_request: + workflow_dispatch: +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created + actions: write + contents: read + strategy: + fail-fast: false + matrix: + version: + - '1.10' + - '1.12' + - 'pre' + os: + - ubuntu-latest + - macos-latest # apple_m1 + - macos-15-intel # intel based macos + - windows-latest # windows + arch: + - x64 + steps: + - uses: actions/checkout@v6 + - uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: julia-actions/cache@v2 + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..ff25ebc --- /dev/null +++ b/.github/workflows/CompatHelper.yml @@ -0,0 +1,18 @@ +name: CompatHelper +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: +jobs: + CompatHelper: + runs-on: ubuntu-latest + steps: + - name: Install CompatHelper + run: using Pkg; Pkg.add("CompatHelper") + shell: julia --color=yes {0} + - name: Run CompatHelper + run: using CompatHelper; CompatHelper.main() + shell: julia --color=yes {0} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..3f42eb1 --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,19 @@ +name: TagBot +on: + issue_comment: + types: + - created + workflow_dispatch: +jobs: + TagBot: + if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + # For commits that modify workflow files: SSH key enables tagging, but + # releases require manual creation. For full automation of such commits, + # use a PAT with `workflow` scope instead of GITHUB_TOKEN. + # See: https://github.com/JuliaRegistries/TagBot#commits-that-modify-workflow-files + ssh: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9619eef..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Documentation: http://docs.travis-ci.com/user/languages/julia/ -language: julia -os: - - linux - - osx -julia: - - 1.0 - - nightly -matrix: - allow_failures: - - julia: nightly - fast_finish: true -notifications: - email: false -after_success: - - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())' -jobs: - include: - - stage: Documentation - julia: 1.0 - os: linux - script: julia --project=docs -e ' - using Pkg; - Pkg.develop(PackageSpec(path=pwd())); - Pkg.instantiate(); - include("docs/make.jl");' - after_success: skip diff --git a/Project.toml b/Project.toml index 194a8ad..d89b697 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BLASFEO" uuid = "2d913c56-f67c-11e9-3afb-9119491b9f4c" version = "0.1.0" -authors = ["Ian McInerney", "Imperial College London"] +authors = ["Anton Pozharskiy ", "Ian McInerney "] [deps] CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" diff --git a/docs/make.jl b/docs/make.jl index fb042d6..b49fd9f 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,6 +1,7 @@ using Documenter, BLASFEO -makedocs(; +makedocs( + ; modules=[BLASFEO], format=Documenter.HTML(), pages=[ @@ -8,7 +9,12 @@ makedocs(; ], repo="https://github.com/JuliaEmbedded/BLASFEO.jl/blob/{commit}{path}#L{line}", sitename="BLASFEO.jl", - authors="Ian McInerney, Imperial College London", + authors="Anton Pozharskiy , Ian McInerney ", + format=Documenter.HTML( + ; + edit_link="master", + assets=String[], + ), assets=String[], ) From a7371b81791e09feffc6b93534c10bf9c8b1cf11 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 15:40:19 +0200 Subject: [PATCH 12/20] update readme --- README.md | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 80d8fad..6573493 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,30 @@ # BLASFEO +| **License** | **Build Status** | **Coverage** | +|:-----------:|:-----------------:|:----------------:|:------------:|:-------:| +| [![License: MIT][license-img]][license-url] | [![build-gh][build-gh-img]][build-gh-url] | [![codecov][codecov-img]][codecov-url] | +[license-img]: https://img.shields.io/badge/License-MIT-yellow.svg +[license-url]: https://github.com/JuliaEmbedded/BLASFEO.jl/blob/master/LICENSE +[build-gh-img]: https://github.com/JuliaEmbedded/BLASFEO.jl/actions/workflows/CI.yml/badge.svg +[build-gh-url]: https://github.com/JuliaEmbedded/BLASFEO.jl/actions/workflows/CI.yml +[codecov-img]: https://codecov.io/gh/JuliaEmbedded/BLASFEO.jl/branch/master/graph/badge.svg?token=MBxH2AAu8Z +[codecov-url]: https://codecov.io/gh/JuliaEmbedded/BLASFEO.jl -[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaembedded.github.io/BLASFEO.jl/stable) -[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliaembedded.github.io/BLASFEO.jl/dev) -[![Build Status](https://travis-ci.org/JuliaEmbedded/BLASFEO.jl.svg?branch=master)](https://travis-ci.org/JuliaEmbedded/BLASFEO.jl) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/juliaembedded/BLASFEO.jl?svg=true)](https://ci.appveyor.com/project/imciner2/BLASFEO-jl) -[![Coveralls](https://coveralls.io/repos/github/JuliaEmbedded/BLASFEO.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaEmbedded/BLASFEO.jl?branch=master) +A Julia package wrapping the [`blasfeo`](https://github.com/giaf/blasfeo) linear algebra library. It is a wrapper around the binary package `blasfeo_jll` which builds architecture specific versions of `blasfeo` for the following hosts: +- `x86_64-[linux|macos|windows]-*` with the following microarchitectures + - `x86_64`: A fallback option, which does not have platform specific code. + - `avx`: For old processors supporting only the original avx extension. + - `avx2`: Modern processors supporting the avx2 extension. + - `avx512`: For platforms supporting `avx512`. **Warning**: this only provides meaningful speedups for >= workstation class AMD ZEN5 CPUs. For others it may even degrade performance. +- `apple_m1-macos-*` for `>=m1` apple architectures. + +Currently other `arm` architectures are unsupported but may be in the future if there are usecases. + +## Installation + +To install `BLASFEO.jl` using +```julia +pkg> add https://github.com/JuliaEmbedded/BLASFEO.jl +``` + +## Usage +TODO: add examples \ No newline at end of file From 26ead23b58c1e99eee1ea8149af872a097c3032e Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 15:42:25 +0200 Subject: [PATCH 13/20] add remaining lvl1 ergonomics wrappers --- src/level1.jl | 24 +++++++++++++++++++++--- test/vec/level1.jl | 8 ++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/level1.jl b/src/level1.jl index a13c734..71e9cdc 100644 --- a/src/level1.jl +++ b/src/level1.jl @@ -37,19 +37,37 @@ for (type,flag) in [ α, x, 0, β, y, 0, y, 0, - )::Cvoid + ) return y end # 3 arg axpby blasfeo_axpby = Symbol(:blasfeo_, flag, :axpby) - @eval function axpby(α::T1, x::$type, β::T2, y::$type, z::$type) where {T1 <: Real, T2 <: Real} + @eval function axpby!(α::T1, x::$type, β::T2, y::$type, z::$type) where {T1 <: Real, T2 <: Real} $blasfeo_axpby( length(x), α, x, 0, β, y, 0, z, 0, - )::Cvoid + ) return z end + + # dvecmul + blasfeo_dvecmul = blasfeo_axpby = Symbol(:blasfeo_, flag, :vecmul) + @eval function vecmul!(x::$type, y::$type, z::$type) + $blasfeo_vecmul( + length(x), + x, 0, + y, 0, + z, 0, + ) + return z + end + + # dvecmulacc + blasfeo_dvecmul = blasfeo_axpby = Symbol(:blasfeo_, flag, :vecmul) + @eval vecmulacc!(x::$type, y::$type, z::$type) = $blasfeo_vecmul(length(x), x, 0, y, 0, z, 0) + + # TODO(@apozharski) givens plane rotations end diff --git a/test/vec/level1.jl b/test/vec/level1.jl index f521128..5a894dc 100644 --- a/test/vec/level1.jl +++ b/test/vec/level1.jl @@ -12,8 +12,12 @@ # Test nondestructively @test dot(a,b) ≈ dot(a_blasfeo, b_blasfeo) - @test (α.*a .+ b) ≈ axpy(α,a_blasfeo,b_blasfeo,c_blasfeo) - @test ((α.*a) .+ (β.*b)) ≈ axpby(α,a_blasfeo,β,b_blasfeo,c_blasfeo) + @test (α.*a .+ b) ≈ axpy!(α,a_blasfeo,b_blasfeo,c_blasfeo) + @test ((α.*a) .+ (β.*b)) ≈ axpby!(α,a_blasfeo,β,b_blasfeo,c_blasfeo) + @test (a .* b) ≈ vecmul!(a_blasfeo, b_blasfeo, c_blasfeo) + fill!(c_blasfeo, 0.0) + @test sum(a .* b) ≈ vecmulacc!(a_blasfeo, b_blasfeo, c_blasfeo) + @test (a .* b) ≈ c_blasfeo # Test destructively axpy!(α,a,b);axpy!(α,a_blasfeo,b_blasfeo) From f7c27d025f3a9c8904069320818cc56dbd6e5fb0 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 15:44:50 +0200 Subject: [PATCH 14/20] adjust README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6573493..6a08dec 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # BLASFEO + | **License** | **Build Status** | **Coverage** | |:-----------:|:-----------------:|:----------------:|:------------:|:-------:| | [![License: MIT][license-img]][license-url] | [![build-gh][build-gh-img]][build-gh-url] | [![codecov][codecov-img]][codecov-url] | From 2999f351c92961a308ad7bdcf2a306bcac2cc9b1 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 15:45:55 +0200 Subject: [PATCH 15/20] more messing with md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a08dec..cbc4caa 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # BLASFEO | **License** | **Build Status** | **Coverage** | -|:-----------:|:-----------------:|:----------------:|:------------:|:-------:| +|:-----------:|:-----------------:|:----------------:| | [![License: MIT][license-img]][license-url] | [![build-gh][build-gh-img]][build-gh-url] | [![codecov][codecov-img]][codecov-url] | + [license-img]: https://img.shields.io/badge/License-MIT-yellow.svg [license-url]: https://github.com/JuliaEmbedded/BLASFEO.jl/blob/master/LICENSE [build-gh-img]: https://github.com/JuliaEmbedded/BLASFEO.jl/actions/workflows/CI.yml/badge.svg From 7c1b0140454b8b9c5c3c220decff6962a1aa1fd2 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 15:57:47 +0200 Subject: [PATCH 16/20] get level1 blas operations correct --- src/BLASFEO.jl | 2 +- src/level1.jl | 26 +++++++++++++++++++------- test/vec/level1.jl | 4 +++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/BLASFEO.jl b/src/BLASFEO.jl index 85d3c7f..9844cc3 100644 --- a/src/BLASFEO.jl +++ b/src/BLASFEO.jl @@ -15,6 +15,6 @@ export BlasfeoDvec, BlasfeoSvec export BlasfeoDmat, BlasfeoSmat # Level 1 -export axpy, axpby +export axpy!, axpby!, vecmul!, vecmulacc!, vecmuldot! end # module diff --git a/src/level1.jl b/src/level1.jl index 71e9cdc..01f76bc 100644 --- a/src/level1.jl +++ b/src/level1.jl @@ -19,7 +19,7 @@ for (type,flag) in [ end # 3 arg axpy - @eval function axpy(α::T, x::$type, y::$type, z::$type) where {T <: Real} + @eval function LinearAlgebra.axpy!(α::T, x::$type, y::$type, z::$type) where {T <: Real} $blasfeo_axpy( length(x), α, x, 0, @@ -43,7 +43,7 @@ for (type,flag) in [ # 3 arg axpby blasfeo_axpby = Symbol(:blasfeo_, flag, :axpby) - @eval function axpby!(α::T1, x::$type, β::T2, y::$type, z::$type) where {T1 <: Real, T2 <: Real} + @eval function LinearAlgebra.axpby!(α::T1, x::$type, β::T2, y::$type, z::$type) where {T1 <: Real, T2 <: Real} $blasfeo_axpby( length(x), α, x, 0, @@ -53,8 +53,8 @@ for (type,flag) in [ return z end - # dvecmul - blasfeo_dvecmul = blasfeo_axpby = Symbol(:blasfeo_, flag, :vecmul) + # vecmul + blasfeo_vecmul = Symbol(:blasfeo_, flag, :vecmul) @eval function vecmul!(x::$type, y::$type, z::$type) $blasfeo_vecmul( length(x), @@ -65,9 +65,21 @@ for (type,flag) in [ return z end - # dvecmulacc - blasfeo_dvecmul = blasfeo_axpby = Symbol(:blasfeo_, flag, :vecmul) - @eval vecmulacc!(x::$type, y::$type, z::$type) = $blasfeo_vecmul(length(x), x, 0, y, 0, z, 0) + # vecmulacc + blasfeo_vecmulacc = Symbol(:blasfeo_, flag, :vecmulacc) + @eval function vecmulacc!(x::$type, y::$type, z::$type) + $blasfeo_vecmulacc( + length(x), + x, 0, + y, 0, + z, 0, + ) + return z + end + + # vecmuldot + blasfeo_vecmuldot = Symbol(:blasfeo_, flag, :vecmuldot) + @eval vecmuldot!(x::$type, y::$type, z::$type) = $blasfeo_vecmuldot(length(x), x, 0, y, 0, z, 0) # TODO(@apozharski) givens plane rotations end diff --git a/test/vec/level1.jl b/test/vec/level1.jl index 5a894dc..305b91d 100644 --- a/test/vec/level1.jl +++ b/test/vec/level1.jl @@ -15,8 +15,10 @@ @test (α.*a .+ b) ≈ axpy!(α,a_blasfeo,b_blasfeo,c_blasfeo) @test ((α.*a) .+ (β.*b)) ≈ axpby!(α,a_blasfeo,β,b_blasfeo,c_blasfeo) @test (a .* b) ≈ vecmul!(a_blasfeo, b_blasfeo, c_blasfeo) + fill!(c_blasfeo, 1.0) + @test (1 .+ a .* b) ≈ vecmulacc!(a_blasfeo, b_blasfeo, c_blasfeo) fill!(c_blasfeo, 0.0) - @test sum(a .* b) ≈ vecmulacc!(a_blasfeo, b_blasfeo, c_blasfeo) + @test sum(a .* b) ≈ vecmuldot!(a_blasfeo, b_blasfeo, c_blasfeo) @test (a .* b) ≈ c_blasfeo # Test destructively From 98a3fcf0f800807e342e1feda3f0582d697343d5 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 16:11:28 +0200 Subject: [PATCH 17/20] use julia native printing to make things consistent --- src/BLASFEO.jl | 1 - src/show.jl | 70 -------------------------------------------------- 2 files changed, 71 deletions(-) delete mode 100644 src/show.jl diff --git a/src/BLASFEO.jl b/src/BLASFEO.jl index 9844cc3..8cba9d7 100644 --- a/src/BLASFEO.jl +++ b/src/BLASFEO.jl @@ -6,7 +6,6 @@ using .LibBlasfeo include("vecs.jl") include("mats.jl") -include("show.jl") include("level1.jl") # Vectors diff --git a/src/show.jl b/src/show.jl deleted file mode 100644 index 199c688..0000000 --- a/src/show.jl +++ /dev/null @@ -1,70 +0,0 @@ -# TODO(@anton) mxn or nxm - -function Base.show(io, A::BlasfeoDmat) - println("$(size(A,1))x$(size(A,2)) BlasfeoDmat:") - blasfeo_print_dmat( - size(A,1), size(A,2), - A.mat, 0, 0, - ) -end - -function Base.show(io, A::BlasfeoSmat) - println("$(size(A,1))x$(size(A,2)) BlasfeoSmat:") - blasfeo_print_smat( - size(A,1), size(A,2), - A.mat, 0, 0, - ) -end - -function Base.show(io, vec::BlasfeoDvec) - println("$(vec.m)-element BlasfeoDvec:") - @ccall blasfeo.blasfeo_print_dvec(vec.m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoDvec}, 0::Cint)::Cvoid -end - -function Base.show(io, vec::BlasfeoSvec) - println("$(vec.m)-element BlasfeoSvec:") - @ccall blasfeo.blasfeo_print_svec(vec.m::Cint, pointer_from_objref(vec)::Ptr{BlasfeoSvec}, 0::Cint)::Cvoid -end - -# TODO(@anton) This is probably not needed, we just need `print_matrix`? this is horribly documented. -for (type,shortname) in [ - (:BlasfeoDvec, :dvec), - (:BlasfeoSvec, :svec), - ] - blasfeo_print_vec = Symbol(:blasfeo_print_,shortname) - @eval begin - function Base.show(io::IO, ::MIME"text/plain", vec::$type) - println("$(length(vec))-element $($type):") - $blasfeo_print_vec(length(vec), vec, 0) - end - - function Base.show(io::IO, vec::$type) - println("$(length(vec))-element $($type):") - $blasfeo_print_vec(length(vec), vec, 0) - end - end -end - -for (type,shortname) in [ - (:BlasfeoDmat, :dmat), - (:BlasfeoSmat, :smat), - ] - blasfeo_print_mat = Symbol(:blasfeo_print_,shortname) - @eval begin - function Base.show(io::IO, ::MIME"text/plain", A::$type) - println("$(size(A,1))x$(size(A,2)) $($type):") - $blasfeo_print_mat( - size(A,1), size(A,2), - A.mat, 0, 0, - ) - end - - function Base.show(io::IO, A::$type) - println("$(size(A,1))x$(size(A,2)) $($type):") - $blasfeo_print_mat( - size(A,1), size(A,2), - A.mat, 0, 0, - ) - end - end -end From 4b2234a27c50a6b7ae8cad781d726fa475a4bbe1 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 18:25:18 +0200 Subject: [PATCH 18/20] some binary and unary arithmetic and more level 1 kernels --- src/BLASFEO.jl | 1 + src/level1.jl | 28 ++++++++++++++++++++++++++++ src/level2.jl | 33 +++++++++++++++++++++++++++++++++ src/vecs.jl | 4 +++- 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/level2.jl diff --git a/src/BLASFEO.jl b/src/BLASFEO.jl index 8cba9d7..2b02a94 100644 --- a/src/BLASFEO.jl +++ b/src/BLASFEO.jl @@ -7,6 +7,7 @@ using .LibBlasfeo include("vecs.jl") include("mats.jl") include("level1.jl") +include("level2.jl") # Vectors export BlasfeoDvec, BlasfeoSvec diff --git a/src/level1.jl b/src/level1.jl index 01f76bc..f4cef71 100644 --- a/src/level1.jl +++ b/src/level1.jl @@ -81,5 +81,33 @@ for (type,flag) in [ blasfeo_vecmuldot = Symbol(:blasfeo_, flag, :vecmuldot) @eval vecmuldot!(x::$type, y::$type, z::$type) = $blasfeo_vecmuldot(length(x), x, 0, y, 0, z, 0) + # veccpsc + blasfeo_veccpsc = Symbol(:blasfeo_, flag, :veccpsc) + @eval function veccpsc!(α::T, x::$type, y::$type) where {T<:Real} + $blasfeo_veccpsc( + length(x), + α, + x, 0, + y, 0, + ) + return y + end + + #### unary arithmetic: + + # unary plus + @eval Base.:+(x::$type) = x + + # unary minus + @eval Base.:-(x::$type) = veccpsc!(-1, x. similar(x)) + + #### binary arithmetic + # binary plus + @eval Base.:+(x::$type, y::$type) = axpy!(1.0, x, y, similar(x)) + @eval Base.:-(x::$type, y::$type) = axpy!(-1.0, y, x, similar(x)) + @eval Base.:*(x::$type, y::$type) = vecmul!(x, y, similar(x)) + @eval Base.:*(x::$type, y::T) where {T<:Real} = veccpsc!(y, x, similar(x)) + @eval Base.:*(x::T, y::$type) where {T<:Real} = veccpsc!(x, y, similar(y)) + # TODO(@apozharski) givens plane rotations end diff --git a/src/level2.jl b/src/level2.jl new file mode 100644 index 0000000..85d26a8 --- /dev/null +++ b/src/level2.jl @@ -0,0 +1,33 @@ + +for (Mat, Vec, flag) in [ + (:BlasfeoDmat, :BlasfeoDvec, :d), + (:BlasfeoSmat, :BlasfeoSvec, :s), + ] + # Overload matrix-vector multiplication + + blasfeo_gemv_n = Symbol(:blasfeo_, flag, :gemv_n) + @eval function Base.:*(A::$Mat, x::$Vec) + z = similar(x) + $blasfeo_gemv_n( + size(A,1), size(A,2), + 1.0, A, 0, 0, + x, 0, + 0.0, x, 0, + z, 0, + ) + return z # A*x + end + + blasfeo_gemv_t = Symbol(:blasfeo_, flag, :gemv_t) + @eval function Base.:*(A::Transpose{eltype($Mat), $Mat}, x::$Vec) + z = similar(x) + $blasfeo_gemv_t( + size(A,1), size(A,2), + 1.0, A, 0, 0, + x, 0, + 0.0, x, 0, + z, 0, + ) + return z # A^T*x + end +end diff --git a/src/vecs.jl b/src/vecs.jl index e5236bb..c57144c 100644 --- a/src/vecs.jl +++ b/src/vecs.jl @@ -79,7 +79,9 @@ for (type,flag) in [ # similar @eval Base.similar(A::$type) = $type(length(A)) - @eval Base.similar(A::$type,dims::Dims{1}) = $type(dims...) + @eval Base.similar(A::$type, dims::Dims{1}) = $type(dims...) + @eval Base.similar(A::$type, ::eltype($type)) = $type(length(A)) + @eval Base.similar(A::$type, ::eltype($type), dims::Dims{1}) = $type(dims...) # copy blasfeo_veccp = Symbol(:blasfeo_, flag, :veccp) From 5ab6298b995bb2e27fdc19ef1ff733aa3fb7b63a Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Mon, 15 Jun 2026 18:29:56 +0200 Subject: [PATCH 19/20] scalar division --- src/level1.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/level1.jl b/src/level1.jl index f4cef71..29d8ad5 100644 --- a/src/level1.jl +++ b/src/level1.jl @@ -94,6 +94,8 @@ for (type,flag) in [ end #### unary arithmetic: + # TODO(@apozharski) all of this is to avoid wierd promotion rules where + # *(Real, BlasfeoDvec) -> Vector{Float64} !? # unary plus @eval Base.:+(x::$type) = x @@ -108,6 +110,10 @@ for (type,flag) in [ @eval Base.:*(x::$type, y::$type) = vecmul!(x, y, similar(x)) @eval Base.:*(x::$type, y::T) where {T<:Real} = veccpsc!(y, x, similar(x)) @eval Base.:*(x::T, y::$type) where {T<:Real} = veccpsc!(x, y, similar(y)) + @eval Base.:\(x::$type, y::T) where {T<:Real} = veccpsc!(inv(y), x, similar(x)) + @eval Base.:\(x::T, y::$type) where {T<:Real} = veccpsc!(inv(x), y, similar(y)) + @eval Base.:/(x::$type, y::T) where {T<:Real} = veccpsc!(inv(y), x, similar(x)) + @eval Base.:/(x::T, y::$type) where {T<:Real} = veccpsc!(inv(x), y, similar(y)) # TODO(@apozharski) givens plane rotations end From 5518c8c667d6e08358f2b9be912f511989a80263 Mon Sep 17 00:00:00 2001 From: Anton Pozharskiy Date: Tue, 16 Jun 2026 18:14:06 +0200 Subject: [PATCH 20/20] add example riccati recursion --- examples/riccati.jl | 159 ++++++++++++++++++++++++++++++++++++++++++++ src/level1.jl | 1 + 2 files changed, 160 insertions(+) create mode 100644 examples/riccati.jl diff --git a/examples/riccati.jl b/examples/riccati.jl new file mode 100644 index 0000000..e986b7a --- /dev/null +++ b/examples/riccati.jl @@ -0,0 +1,159 @@ +using BLASFEO +using BLASFEO.LibBlasfeo + +struct OcpStructuredLinearSystem + N::Int + x0::BlasfeoDvec + nx::Vector{Int} + nu::Vector{Int} + BAbt::Vector{BlasfeoDmat} + RSQrq::Vector{BlasfeoDmat} + L::Vector{BlasfeoDmat} + ux::Vector{BlasfeoDvec} + pi::Vector{BlasfeoDvec} + work_mat::BlasfeoDmat + work_vec::BlasfeoDvec +end + +function OcpStructuredLinearSystem( + As::Vector{<:AbstractArray{Float64}}, + Bs::Vector{<:AbstractArray{Float64}}, + bs::Vector{<:AbstractArray{Float64}}, + Qs::Vector{<:AbstractArray{Float64}}, + qs::Vector{<:AbstractArray{Float64}}, + Rs::Vector{<:AbstractArray{Float64}}, + rs::Vector{<:AbstractArray{Float64}}, + Ss::Vector{<:AbstractArray{Float64}}, + x0::Vector{Float64} + ) + # Do no size checks :P + N = length(Bs) + nx = [0; [size(A,1) for A in As]] + nu = [[size(B,2) for B in Bs]; 0] + ux = [BlasfeoDvec(nx[ii]+nu[ii]+1) for ii in 1:N+1] + pi = [BlasfeoDvec(nx[ii]) for ii in 1:N+1] + + # Adjust bs[1] + bs[1] += As[1]*x0 + + BAbt = Vector{BlasfeoDmat}(undef, N) + RSQrq = Vector{BlasfeoDmat}(undef, N+1) + L = [BlasfeoDmat(nx[ii]+nu[ii]+1, nx[ii]+nu[ii]) for ii in 1:N+1] + BAbt[1] = BlasfeoDmat(permutedims(hcat(Bs[1],bs[1]))) + RSQrq[1] = BlasfeoDmat([Rs[1]; rs[1]]) + for ii in 2:N + BAbt[ii] = BlasfeoDmat(permutedims(hcat(Bs[ii],As[ii],bs[ii]))) + RSQ = vcat( + hcat(Rs[ii],zeros(nu[ii],nx[ii])), + hcat(Ss[ii], Qs[ii]), + permutedims(vcat(rs[ii], qs[ii])), + ) + RSQrq[ii] = BlasfeoDmat(RSQ) + end + RSQrq[N+1] = BlasfeoDmat(vcat(Qs[N+1],transpose(qs[N+1]))) + + return OcpStructuredLinearSystem( + N, + BlasfeoDvec(x0), + nx, + nu, + BAbt, + RSQrq, + L, + ux, + pi, + BlasfeoDmat(maximum(nu) + maximum(nx) + 1, maximum(nx)), + BlasfeoDvec(maximum(nx)), + ) +end + + +function simple_model(N;x0=[-1;-1.]) + As = [[1. 1.; 0. 1.] for i in 1:N] + Bs = [[0.; 1;;] for i in 1:N] + bs = [[0.1; 0.1] for i in 1:N] + Qs = push!([[1. 0.; 0. 1.] for i in 1:N],[10. 0.;0. 10.]) + qs = push!([[0.1; 0.1] for i in 1:N],[10. ; 10.]) + Ss = [[0.; 0.] for i in 1:N] + Rs = [[1.;;] for i in 1:N] + rs = [[0.1] for i in 1:N] + + return As, Bs, bs, Qs, qs, Rs, rs, Ss, x0 +end + +""" + An example riccati recursion solver via the thin-wrapper interface +""" +function riccati(kkt::OcpStructuredLinearSystem) + N = kkt.N + nx = kkt.nx + nu = kkt.nu + RSQrq = kkt.RSQrq + BAbt = kkt.BAbt + ux = kkt.ux + pi = kkt.pi + work_mat = kkt.work_mat + work_vec = kkt.work_vec + L = kkt.L + nx_end = kkt.nx[N+1] + # Factorize last stage Q + blasfeo_dpotrf_l_mn(nx_end+1,nx_end, RSQrq[N+1], 0, 0, L[N+1], 0, 0) + + for ii in N:-1:1 + blasfeo_dtrmm_rlnn( + nu[ii]+nx[ii]+1, + nx[ii+1], + 1.0, L[ii+1], nu[ii+1], nu[ii+1], + BAbt[ii], 0, 0, + work_mat, 0, 0, + ) + blasfeo_dgead( + 1, nx[ii+1], + 1.0, + L[ii+1], nu[ii+1]+nx[ii+1], nu[ii+1], + work_mat, nu[ii]+nx[ii], 0, + ) + + blasfeo_dsyrk_dpotrf_ln_mn( + nu[ii]+nx[ii]+1, + nu[ii]+nx[ii], + nx[ii+1], + work_mat, 0, 0, + work_mat, 0, 0, + RSQrq[ii], 0, 0, + L[ii], 0, 0 + ) + end + + blasfeo_drowex(nu[1]+nx[1], -1.0, L[1], nu[1]+nx[1], 0, ux[1], 0) + blasfeo_dtrsv_ltn(nu[1]+nx[1], L[1], 0, 0, ux[1], 0, ux[1], 0) + blasfeo_drowex(nx[2], 1.0, BAbt[1], nu[1]+nx[1], 0, ux[2], nu[2]) + blasfeo_dgemv_t(nu[1]+nx[1], nx[2], 1.0, BAbt[1], 0, 0, ux[1], 0, 1.0, ux[2], nu[2], ux[2], nu[2]) + blasfeo_dveccp(nx[2], ux[2], nu[2], pi[1], 0) + blasfeo_drowex(nx[2], 1.0, L[2], nu[2]+nx[2], nu[2], work_vec, 0) + blasfeo_dtrmv_ltn(nx[2], L[2], nu[2], nu[2], pi[1], 0, pi[1], 0) + blasfeo_daxpy(nx[2], 1.0, work_vec, 0, pi[1], 0, pi[1], 0) + blasfeo_dtrmv_lnn(nx[2], L[2], nu[2], nu[2], pi[1], 0, pi[1], 0) + + for ii in 2:N + blasfeo_drowex(nu[ii], -1.0, L[ii], nu[ii]+nx[ii], 0, ux[ii], 0) + blasfeo_dtrsv_ltn_mn(nu[ii]+nx[ii], nu[ii], L[ii], 0, 0, ux[ii], 0, ux[ii], 0) + blasfeo_drowex(nx[ii+1], 1.0, BAbt[ii], nu[ii]+nx[ii], 0, ux[ii+1], nu[ii+1]) + blasfeo_dgemv_t(nu[ii]+nx[ii], nx[ii+1], 1.0, BAbt[ii], 0, 0, ux[ii], 0, 1.0, ux[ii+1], nu[ii+1], ux[ii+1], nu[ii+1]) + blasfeo_dveccp(nx[ii+1], ux[ii+1], nu[ii+1], pi[ii], 0) + blasfeo_drowex(nx[ii+1], 1.0, L[ii+1], nu[ii+1]+nx[ii+1], nu[ii+1], work_vec, 0) + blasfeo_dtrmv_ltn(nx[ii+1], L[ii+1], nu[ii+1], nu[ii+1], pi[ii], 0, pi[ii], 0) + blasfeo_daxpy(nx[ii+1], 1.0, work_vec, 0, pi[ii], 0, pi[ii], 0) + blasfeo_dtrmv_lnn(nx[ii+1], L[ii+1], nu[ii+1], nu[ii+1], pi[ii], 0, pi[ii], 0) + end +end + +function get_u(kkt::OcpStructuredLinearSystem) + return [kkt.ux[ii][1:kkt.nu[ii]] for ii in 1:kkt.N] +end + +function get_x(kkt::OcpStructuredLinearSystem) + x = [kkt.ux[ii][kkt.nu[ii]+1:kkt.nu[ii]+kkt.nx[ii]] for ii in 1:kkt.N+1] + x[1] = kkt.x0 + return x +end diff --git a/src/level1.jl b/src/level1.jl index 29d8ad5..fdf327a 100644 --- a/src/level1.jl +++ b/src/level1.jl @@ -96,6 +96,7 @@ for (type,flag) in [ #### unary arithmetic: # TODO(@apozharski) all of this is to avoid wierd promotion rules where # *(Real, BlasfeoDvec) -> Vector{Float64} !? + # But is there a better way? # unary plus @eval Base.:+(x::$type) = x