Skip to content

Commit 03072e4

Browse files
docs: add docstring for array_literal
1 parent a06a493 commit 03072e4

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

docs/src/manual/variants.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ variant. This variant can be constructed using `Const{T}(val)` or `BSImpl.Const{
108108
where `T` is the appropriate `vartype`.
109109

110110
The `Const` constructors have an additional special behavior. If given an array of symbolics
111-
(or array of array of ... symbolics), it will return a `Term` (see below) with [`array_literal`](@ref)
112-
as the operation. This allows standard symbolic operations (such as [`substitute`](@ref)) to
113-
work on arrays of symbolics without excessive special-case handling and improved
114-
type-stability.
111+
(or array of array of ... symbolics), it will return a `Term` (see below) with
112+
[`SymbolicUtils.array_literal`](@ref) as the operation. This allows standard symbolic
113+
operations (such as [`substitute`](@ref)) to work on arrays of symbolics without excessive
114+
special-case handling and improved type-stability.
115115

116116
```julia
117117
struct Sym

src/types.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,15 @@ function _is_tuple_of_symbolics(O::Tuple)
14841484
end
14851485
_is_tuple_of_symbolics(O) = false
14861486

1487+
"""
1488+
$TYPEDSIGNATURES
1489+
1490+
Utility function used as the operation of expressions representing an array of symbolic values.
1491+
See [`SymbolicUtils.BSImpl.Const`](@ref) for more details.
1492+
1493+
The first argument `sz` is the `size` of the represented array. `args...` is `prod(sz)`
1494+
elements representing the elements of the array in column-major order.
1495+
"""
14871496
array_literal(sz::NTuple{N, Int}, args...) where {N} = reshape(Base.vect(args...), sz)
14881497

14891498
"""
@@ -1502,7 +1511,8 @@ arrays/tuples of symbolics to symbolic expressions.
15021511
This is the low-level constructor for constant expressions. It handles several special cases:
15031512
1. If `val` is already a `BasicSymbolic{T}`, returns it unchanged
15041513
2. If `val` is a `BasicSymbolic` of a different variant type, throws an error
1505-
3. If `val` is an array containing symbolic elements, creates a `Term` with [`array_literal`](@ref) operation
1514+
3. If `val` is an array containing symbolic elements, creates a `Term` with
1515+
[`SymbolicUtils.array_literal`](@ref) operation
15061516
4. If `val` is a tuple containing symbolic elements, creates a `Term` with `tuple` operation
15071517
5. Otherwise, creates a `Const` variant wrapping the value
15081518

0 commit comments

Comments
 (0)