-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
- Transposing a matrix is an expensive operation that should be avoided if at all possible
- The Tasmanian C library uses only vectors as input or output arguments
- In Julia, one can pass a matrix to ccall vector argument. The vector is just the continuous memory space occupied by the Julia matrix.
- The Tasmanian vector is formed by a succession of strips of data piled on top of each others. As a Julia matrix is stored column wise, the most efficient is to have the Julia matrix columns to correspond to the strips of data
Example:
# load needed points
"""
loadNeededPoints!(tsg::TasmanianSG, vals::Matrix{Float64})
loads the values of the target function at the needed points
if there are no needed points, this reset the currently loaded
values
vals: a matrix
with dimensions iOutputs X getNumNeeded()
each column corresponds to the values of the outputs at
the corresponding needed point. The order and leading
dimension must match the points obtained from
getNeededPoints()
"""
function loadNeededPoints!(tsg::TasmanianSG,vals::Array{Float64})
if ndims(vals) != 2
throw(ArgumentError("vals should be a 2-D array, instead it has $(ndims(vals)) dimensions"))
end
n = size(vals)
if n[1] != getNumOutputs(tsg)
throw(ArgumentError("leading dimension of vals is $(n[1]) but the number of outputs is set to $(getNumOutputs(tsg))"))
end
if getNumNeeded(tsg) == 0
if n[2] != getNumLoaded(tsg)
throw(ArgumentError("the second dimension of vals is $(n[2]) but the number of current points is $(getNumLoaded(tsg))"))
end
elseif n[2] != getNumNeeded(tsg)
throw(ArgumentError("the second dimension of vals is $(n[2]) but the number of needed points is $(getNumNeeded(tsg))"))
end
ccall((:tsgLoadNeededPoints,TASlib),Nothing,(Ptr{Nothing},Ptr{Cdouble}),tsg.pGrid,vals)
end
Metadata
Metadata
Assignees
Labels
No labels