CeedVector
LibCEED.CeedVector — TypeCeedVector(c::Ceed, len::Integer)Creates a CeedVector of given length.
CeedVector(c::Ceed, v2::AbstractVector; mtype=MEM_HOST, cmode=COPY_VALUES)Creates a new CeedVector using the contents of the given vector v2. By default, the contents of v2 will be copied to the new CeedVector, but this behavior can be changed by specifying a different cmode.
LibCEED.setvalue! — Functionsetvalue!(v::CeedVector, val::Real)Set the CeedVector to a constant value.
Base.setindex! — Methodsetindex!(v::CeedVector, val::Real)
v[] = valSet the CeedVector to a constant value, synonymous to setvalue!.
Base.setindex! — Methodsetindex!(v::CeedVector, v2::AbstractArray)
v[] = v2Sets the values of CeedVector v equal to those of v2 using broadcasting.
Base.Vector — MethodVector(v::CeedVector)Create a new Vector by copying the contents of v.
LinearAlgebra.norm — Methodnorm(v::CeedVector, ntype::NormType)Return the norm of the given CeedVector.
The norm type can either be specified as one of NORM_1, NORM_2, NORM_MAX.
LinearAlgebra.norm — Methodnorm(v::CeedVector, p::Real)Return the norm of the given CeedVector, see norm(::CeedVector, ::NormType).
p can have value 1, 2, or Inf, corresponding to NORM_1, NORM_2, and NORM_MAX, respectively.
LibCEED.@witharray — Macro@witharray(v_arr=v, [size=(dims...)], [mtype=MEM_HOST], body)Executes body, having extracted the contents of the CeedVector v as an array with name v_arr. If the memory type mtype is not provided, MEM_HOST will be used. If the size is not specified, a flat vector will be assumed.
Examples
Negate the contents of CeedVector v:
@witharray v_arr=v v_arr .*= -1.0LibCEED.@witharray_read — Macro@witharray_read(v_arr=v, [size=(dims...)], [mtype=MEM_HOST], body)Same as @witharray, but provides read-only access to the data.
LibCEED.witharray — Functionwitharray(f, v::CeedVector, mtype=MEM_HOST)Calls f with an array containing the data of the CeedVector v, using memory type mtype.
Because of performance issues involving closures, if f is a complex operation, it may be more efficient to use the macro version @witharray (cf. the section on "Performance of captured variable" in the Julia documentation and related GitHub issue.
Examples
Return the sum of a vector:
witharray(sum, v)LibCEED.witharray_read — Functionwitharray_read(f, v::CeedVector, mtype::MemType=MEM_HOST)Same as witharray, but with read-only access to the data.
Examples
Display the contents of a vector:
witharray_read(display, v)LibCEED.setarray! — Functionsetarray!(v::CeedVector, mtype::MemType, cmode::CopyMode, arr)Set the array used by a CeedVector, freeing any previously allocated array if applicable. The backend may copy values to a different MemType. See also syncarray! and takearray!.
The CopyMode OWN_POINTER is not suitable for use with arrays that are allocated by Julia, since those cannot be properly freed from libCEED.
LibCEED.syncarray! — Functionsyncarray!(v::CeedVector, mtype::MemType)Sync the CeedVector to a specified MemType. This function is used to force synchronization of arrays set with setarray!. If the requested memtype is already synchronized, this function results in a no-op.
LibCEED.takearray! — Functiontakearray!(v::CeedVector, mtype::MemType)Take ownership of the CeedVector array and remove the array from the CeedVector. The caller is responsible for managing and freeing the array. The array is returns as a Ptr{CeedScalar}.
LibCEED.scale! — Functionscale!(v::CeedVector, a::Real)Overwrite v with a*v for scalar a. Returns v.
LinearAlgebra.axpy! — Methodaxpy!(a::Real, x::CeedVector, y::CeedVector)Overwrite y with x*a + y, where a is a scalar. Returns y.
In order to be consistent with LinearAlgebra.axpy!, the arguments are passed in order: a, x, y. This is different than the order of arguments of the C function CeedVectorAXPY.
LibCEED.pointwisemult! — Functionpointwisemult!(w::CeedVector, x::CeedVector, y::CeedVector)Overwrite w with x .* y. Any subset of x, y, and w may be the same vector. Returns w.