removed null space related code as obsolete

This commit is contained in:
Jukka Aho
2017-01-05 07:14:54 +02:00
parent 4b5e7a204e
commit 868db9ee2e
3 changed files with 12 additions and 145 deletions
-49
View File
@@ -184,55 +184,6 @@ function get_boundary_assembly(solver::Solver)
return K, C1, C2, D, f, g
end
function resize!(A::SparseMatrixCSC, m::Int64, n::Int64)
(n == A.n) && (m == A.m) && return
@assert n >= A.n
@assert m >= A.m
append!(A.colptr, A.colptr[end]*ones(Int, m-A.m))
A.n = n
A.m = m
end
"""
Given C and g, construct new basis such that v = P*u + g
Parameters
----------
S set of linearly independent dofs.
"""
function create_projection(C::SparseMatrixCSC, g; S=nothing, tol=1.0e-12)
n, m = size(C)
@assert n == m
if S == nothing
S = get_nonzero_rows(C)
end
# FIXME: this creates dense matrices
# efficiency / memory usage is a question
M = get_nonzero_columns(C)
F = qrfact(C[S,:])
P = spzeros(n,m)
P[:,M] = sparse(F \ full(C[S,M]))
h = sparse(F \ full(g[S]))
resize!(P, n, m)
resize!(h, n, 1)
P = speye(n) - P
droptol!(P, tol)
return P, h
end
""" Assume C is invertible. """
function create_projection(C, g, ::Type{Val{:invertible}})
nz1, nz2 = get_nonzeros(C)
P = spzeros(size(C)...)
for j=1:size(C,1)
j in nz1 && continue
P[j,j] = 1.0
end
v = lufact(C[nz1,nz2]) \ full(g[nz1])
return P, v
end
"""
Solve linear system using LDLt factorization (SuiteSparse). This version
+12 -2
View File
@@ -178,11 +178,21 @@ function size(A::SparseMatrixCOO, idx::Int)
return size(A)[idx]
end
""" Resize sparse matrix A to (higher) dimension n x m. """
function resize_sparse(A, n, m)
return sparse(findnz(A)..., n, m)
end
""" Resize sparse vector b to (higher) dimension n. """
function resize_sparsevec(b, n)
return sparsevec(findnz(b)..., n)
end
""" Matrix norm. Automatically convert to dense when asking for 2-norm for small matrices. """
function norm(A::SparseMatrixCOO, p=Inf; maxdim=1000)
dim = size(A, 1)
if p == 2 && dim > maxdim
info("Assembly norm: dim = $dim > $maxdim and p=$p, not making dense matrices for operation.")
warn("Assembly norm: dim = $dim > $maxdim and p=$p, not making dense matrices for operation.")
return 0.0
end
if p == 2
@@ -192,9 +202,9 @@ function norm(A::SparseMatrixCOO, p=Inf; maxdim=1000)
end
end
""" Approximative comparison of two matricse A and B. """
function isapprox(A::SparseMatrixCOO, B::SparseMatrixCOO)
A2 = sparse(A)
B2 = sparse(B, size(A2)...)
return isapprox(A2, B2)
end