66function quad (x:: Vector , param)
77 mat = param. mat
88 xt = x- param. vec
9- return 0.5 * vecdot (xt, mat* xt)
9+ return 0.5 * dot (xt, mat* xt)
1010end
1111
1212function quad_gradient! (storage:: Vector , x:: Vector , param)
@@ -19,7 +19,7 @@ function quad_fun_gradient!(storage::Vector, x::Vector, param)
1919 mat = param. mat
2020 xt = x- param. vec
2121 storage .= mat* xt
22- return 0.5 * vecdot (xt, mat* xt)
22+ return 0.5 * dot (xt, mat* xt)
2323end
2424
2525function quad_hessian! (storage:: Matrix , x:: Vector , param)
@@ -32,7 +32,7 @@ struct MatVecHolder{Tv <: AbstractVector,
3232 vec:: Tv
3333end
3434
35- function _quadraticproblem (N:: Int ; mat:: AbstractArray{T,2} = spdiagm ( float (1 : N)),
35+ function _quadraticproblem (N:: Int ; mat:: AbstractArray{T,2} = sparse ( Diagonal ( float (1 : N) )),
3636 x0:: AbstractVector{T} = ones (N),
3737 initial_x:: AbstractVector{T} = zeros (N),
3838 name:: AbstractString = " Quadratic Diagonal ($N )" ) where T <: Number
@@ -72,7 +72,7 @@ function paraboloid(x::AbstractArray, param::ParaboloidStruct)
7272 @. xt = x - param. vec
7373 xt[2 : end ] .- = param. alpha* xt[1 ]^ 2
7474
75- return 0.5 * vecdot (xt, mat* xt)
75+ return 0.5 * dot (xt, mat* xt)
7676end
7777
7878function paraboloid_gradient! (storage:: AbstractArray , x:: AbstractArray , param:: ParaboloidStruct )
@@ -97,14 +97,14 @@ function paraboloid_fun_gradient!(storage::AbstractArray, x::AbstractArray, para
9797 storage .= mat* xt
9898 storage[1 ] -= 2.0 * param. alpha* xt[1 ]* sum (storage[2 : end ])
9999
100- return 0.5 * vecdot (xt, mat* xt)
100+ return 0.5 * dot (xt, mat* xt)
101101end
102102
103103function paraboloid_hessian! (storage,x,param)
104104 error (" Hessian not implemented for Paraboloid" )
105105end
106106
107- function _paraboloidproblem (N:: Int ; mat:: AbstractArray{T,2} = spdiagm ( float (1 : N)),
107+ function _paraboloidproblem (N:: Int ; mat:: AbstractArray{T,2} = sparse ( Diagonal ( float (1 : N) )),
108108 x0:: AbstractVector{T} = ones (N),
109109 initial_x:: AbstractVector{T} = zeros (N),
110110 alpha:: T = 10.0 ,
@@ -126,21 +126,17 @@ end
126126examples[" Paraboloid Diagonal" ] = _paraboloidproblem (100 )
127127
128128function _randommatrix (N:: Int , scaling:: Bool = true )
129- F = qrfact (randn (N,N))
129+ F = qr (randn (N,N))
130130 if scaling
131- retval = F[ :Q ] ' * spdiagm ( float (1 : N))* F[ :Q ]
131+ retval = F. Q ' * sparse ( Diagonal ( float (1 : N))) * F . Q
132132 else
133- retval = F[ :Q ] ' * F[ :Q ]
133+ retval = F. Q ' * F. Q
134134 end
135135 retval
136136end
137137
138- # TODO : From Julia 0.7 onwards, we can use Base.Test.guardsrand() to restore the existing seed
139- oldseed = copy (Base. GLOBAL_RNG) # Store current seed
140-
141- srand (0 )
138+ guardsrand (0 ) do
142139examples[" Paraboloid Random Matrix" ] = _paraboloidproblem (100 ;
143140 name = " Paraboloid Random Matrix (100)" ,
144141 mat = _randommatrix (100 ))
145-
146- copy! (Base. GLOBAL_RNG, oldseed) # Restore current seed
142+ end
0 commit comments