ConjugateGradientMethod.cg!Method
cg!(x, A, b, [iterpart=1.0])
cg!(x, A, b, [iternum=size(A,1)])

Solves the least squares problem $\min\|Ax - b\|^2$ using conjugate gradient method. x is used as an initial value and is replaced with the result.

iternum specifies the number of iterations to stop after (minimum 1).

Examples

julia> x = zeros(2);

julia> cg!(x, [1 2; 3 4], [1, 2])
2-element Array{Float64,1}:
5.551115123125783e-17
0.5000000000000012

See also cg and @cg.

ConjugateGradientMethod.cgMethod
cg(A, b, [iterpart=1.0])
cg(A, b, [iternum=size(A,1)])

Solves the least squares problem $\min\|Ax - b\|^2$ using conjugate gradient method. To use initial value see cg!.

iternum specifies the number of iterations to stop after (minimum 1). iterpart = iternum / $size(A,1)$

Examples

julia> cg([1 2; 3 4], [1, 2])
2-element Array{Float64,1}:
5.551115123125783e-17
0.5000000000000012

See also cg! and @cg.

ConjugateGradientMethod.close!Method
ConjugateGradientMethod.close!(x) = nothing

function that is called after arrays inside cg method are no longer needed.

can be redefined by user to free memory.

ConjugateGradientMethod.dotMethod
ConjugateGradientMethod.dot(x, y) = LinearAlgebra.dot(x, y)

dot product function, used in cg method.

ConjugateGradientMethod.mul!Method
ConjugateGradientMethod.mul!(y, A, x) = LinearAlgebra.mul!(y, A, x)

matrix-vector multilpication function, used in cg method.

ConjugateGradientMethod.@cgMacro
@cg [1.0] A \ b

Solves the least squares problem $\min\|Ax - b\|^2$ using conjugate gradient method.

Between @cg and rdiv call iterpart can be specified.

Examples

julia> @cg [1 2; 3 4] \ [1, 2]
2-element Array{Float64,1}:
5.551115123125783e-17
0.5000000000000012

julia> @cg 0.5 [1 2; 3 4] \ [1, 2]
2-element Array{Float64,1}:
0.2343820224719101
0.33483146067415726

See also cg and cg!.