+<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>The AbstractVectorOfArray and AbstractDiffEqArray Interfaces · RecursiveArrayTools.jl</title><meta name="title" content="The AbstractVectorOfArray and AbstractDiffEqArray Interfaces · RecursiveArrayTools.jl"/><meta property="og:title" content="The AbstractVectorOfArray and AbstractDiffEqArray Interfaces · RecursiveArrayTools.jl"/><meta property="twitter:title" content="The AbstractVectorOfArray and AbstractDiffEqArray Interfaces · RecursiveArrayTools.jl"/><meta name="description" content="Documentation for RecursiveArrayTools.jl."/><meta property="og:description" content="Documentation for RecursiveArrayTools.jl."/><meta property="twitter:description" content="Documentation for RecursiveArrayTools.jl."/><meta property="og:url" content="https://docs.sciml.ai/RecursiveArrayTools/stable/AbstractVectorOfArrayInterface/"/><meta property="twitter:url" content="https://docs.sciml.ai/RecursiveArrayTools/stable/AbstractVectorOfArrayInterface/"/><link rel="canonical" href="https://docs.sciml.ai/RecursiveArrayTools/stable/AbstractVectorOfArrayInterface/"/><script data-outdated-warner src="../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../search_index.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-mocha.css" data-theme-name="catppuccin-mocha"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-macchiato.css" data-theme-name="catppuccin-macchiato"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-frappe.css" data-theme-name="catppuccin-frappe"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-latte.css" data-theme-name="catppuccin-latte"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script><link href="../assets/favicon.ico" rel="icon" type="image/x-icon"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../"><img src="../assets/logo.png" alt="RecursiveArrayTools.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit"><a href="../">RecursiveArrayTools.jl</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li><a class="tocitem" href="../">Home</a></li><li><a class="tocitem" href="../breaking_changes_v4/">Breaking Changes in v4.0: AbstractArray Interface</a></li><li class="is-active"><a class="tocitem" href>The AbstractVectorOfArray and AbstractDiffEqArray Interfaces</a></li><li><a class="tocitem" href="../array_types/">Recursive Array Types</a></li><li><a class="tocitem" href="../ragged_arrays/">Ragged Arrays</a></li><li><a class="tocitem" href="../subpackages/">Subpackages</a></li><li><a class="tocitem" href="../plotting/">Plotting</a></li><li><a class="tocitem" href="../recursive_array_functions/">Recursive Array Functions</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>The AbstractVectorOfArray and AbstractDiffEqArray Interfaces</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>The AbstractVectorOfArray and AbstractDiffEqArray Interfaces</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/SciML/RecursiveArrayTools.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/SciML/RecursiveArrayTools.jl/blob/master/docs/src/AbstractVectorOfArrayInterface.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="The-AbstractVectorOfArray-and-AbstractDiffEqArray-Interfaces"><a class="docs-heading-anchor" href="#The-AbstractVectorOfArray-and-AbstractDiffEqArray-Interfaces">The AbstractVectorOfArray and AbstractDiffEqArray Interfaces</a><a id="The-AbstractVectorOfArray-and-AbstractDiffEqArray-Interfaces-1"></a><a class="docs-heading-anchor-permalink" href="#The-AbstractVectorOfArray-and-AbstractDiffEqArray-Interfaces" title="Permalink"></a></h1><article><details class="docstring" open="true"><summary id="RecursiveArrayTools.AbstractVectorOfArray"><a class="docstring-binding" href="#RecursiveArrayTools.AbstractVectorOfArray"><code>RecursiveArrayTools.AbstractVectorOfArray</code></a> — <span class="docstring-category">Type</span></summary><section><div><pre><code class="language-julia hljs">AbstractVectorOfArray{T, N, A}</code></pre><p>An AbstractVectorOfArray is an object which represents arrays of arrays, and arbitrary recursive nesting of arrays, as a single array-like object. Thus a canonical example of an AbstractVectorOfArray is something of the form <code>VectorOfArray([[1,2],[3,4]])</code>, which "acts" like the matrix <code>[1 3; 2 4]</code> where the data is stored and accessed in a column-ordered fashion (as is typical in Julia), but the actual matrix is never constructed and instead lazily represented through the type.</p><p>An AbstractVectorOfArray subtype should match the following behaviors.</p><div class="admonition is-info" id="Note-f7bd0c11d377fec5"><header class="admonition-header">Note<a class="admonition-anchor" href="#Note-f7bd0c11d377fec5" title="Permalink"></a></header><div class="admonition-body"><p>As of v4.0, <code>AbstractVectorOfArray <: AbstractArray</code>. Linear indexing <code>A[i]</code> now returns the <code>i</code>th element in column-major order, matching standard Julia <code>AbstractArray</code> behavior. To access the <code>i</code>th inner array, use <code>A.u[i]</code> or <code>A[:, i]</code>. For ragged arrays (inner arrays of different sizes), <code>size(A)</code> reports the maximum size in each dimension and out-of-bounds elements are interpreted as zero (sparse representation). This means all standard linear algebra operations work out of the box.</p></div></div><p><strong>Fields</strong></p><p>An AbstractVectorOfArray has the following fields:</p><ul><li><code>u</code> which holds the Vector of values at each timestep</li></ul><p><strong>Array Interface</strong></p><p>The general operations are as follows. Use</p><pre><code class="language-julia hljs">A.u[j]</code></pre><p>to access the <code>j</code>th array. For multidimensional systems, this will address first by component and lastly by time, and thus</p><pre><code class="language-julia hljs">A[i, j]</code></pre><p>will be the <code>i</code>th component at array <code>j</code>. Hence, <code>A[j][i] == A[i, j]</code>. This is done because Julia is column-major, so the leading dimension should be contiguous in memory. If the independent variables had shape (for example, was a matrix), then <code>i</code> is the linear index. We can also access solutions with shape:</p><pre><code class="language-julia hljs">A[i, k, j]</code></pre><p>gives the <code>[i,k]</code> component of the system at array <code>j</code>. The colon operator is supported, meaning that</p><pre><code class="language-julia hljs">A[i, :]</code></pre><p>gives the timeseries for the <code>i</code>th component.</p><p><strong>Using the AbstractArray Interface</strong></p><p>The <code>AbstractArray</code> interface can be directly used. For example, for a vector system of variables <code>A[i,j]</code> is a matrix with rows being the variables and columns being the timepoints. Operations like <code>A'</code> will transpose the solution type. Functionality written for <code>AbstractArray</code>s can directly use this. For example, the Base <code>cov</code> function computes correlations amongst columns, and thus:</p><pre><code class="language-julia hljs">cov(A)</code></pre><p>computes the correlation of the system state in time, whereas</p><pre><code class="language-julia hljs">cov(A, 2)</code></pre><p>computes the correlation between the variables. Similarly, <code>mean(A,2)</code> is the mean of the variable in time, and <code>var(A,2)</code> is the variance. Other statistical functions and packages which work on <code>AbstractArray</code> types will work on the solution type.</p><p><strong>Conversions</strong></p><p>At anytime, a true <code>Array</code> can be created using <code>Array(A)</code>, or more generally <code>stack(A)</code> to make the array type match the internal array type (for example, if <code>A</code> is an array of GPU arrays, <code>stack(A)</code> will be a GPU array).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/SciML/RecursiveArrayTools.jl/blob/6a720b5ea61fb924269ee88266b5afb99ebfab35/src/RecursiveArrayTools.jl#L14-L105">source</a></section></details></article><article><details class="docstring" open="true"><summary id="RecursiveArrayTools.AbstractDiffEqArray"><a class="docstring-binding" href="#RecursiveArrayTools.AbstractDiffEqArray"><code>RecursiveArrayTools.AbstractDiffEqArray</code></a> — <span class="docstring-category">Type</span></summary><section><div><pre><code class="language-julia hljs">AbstractDiffEqArray{T, N, A} <: AbstractVectorOfArray{T, N, A}</code></pre><p>An AbstractVectorOfArray object which has extra information of a time array <code>A.t</code> in order to specify a time series. A canonical AbstractDiffEqArray is for example the pairing <code>DiffEqArray([[1,2],[3,4]],[1.0,2.0])</code> which means that at time 1.0 the values were <code>[1,2]</code> and at time 2.0 the values were <code>[3,4]</code>.</p><p>An AbstractDiffEqArray has all of the same behaviors as an AbstractVectorOfArray with the additional properties:</p><p><strong>Fields</strong></p><p>An AbstractDiffEqArray adds the following fields:</p><ul><li><code>t</code> which holds the times of each timestep.</li><li><code>p</code> which holds the parameter values.</li><li><code>sys</code> which holds the symbolic system (e.g. <code>SymbolCache</code>).</li><li><code>discretes</code> which holds discrete parameter timeseries.</li><li><code>interp</code> which holds an interpolation object for dense output (default <code>nothing</code>).</li><li><code>dense</code> which indicates whether dense interpolation is available (default <code>false</code>).</li></ul><p><strong>Callable Interface</strong></p><p>When <code>interp</code> is not <code>nothing</code>, the array supports callable syntax for interpolation:</p><pre><code class="language-julia hljs">da(t) # interpolate at time t
0 commit comments