RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • blkdiag
    • cat
    • circshift
    • diag
    • flip
    • fliplr
    • flipud
    • horzcat
    • ipermute
    • kron
    • permute
    • repelem
    • repmat
    • reshape
    • rot90
    • squeeze
    • toeplitz
    • tril
    • triu
    • vertcat

flipud — Flip arrays up-to-down in MATLAB and RunMat.

flipud(A) mirrors A across its horizontal axis by reversing row order (dimension 1). Inputs with fewer than two rows are unchanged. Numeric, logical, complex, text, cell, and gpuArray paths are implemented; broader object parity remains pending.

Syntax

B = flipud(A)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Input array/value to reverse along rows.

Returns

NameTypeDescription
BAnyInput array mirrored up-to-down (dimension 1).

Errors

IdentifierWhenMessage
RunMat:flipud:InvalidInputInput type or conversion path is invalid for flipud.flipud: invalid input argument
RunMat:flipud:UnsupportedInputInput type is unsupported for flipud.flipud: unsupported input type

How flipud works

  • Always reverses dimension 1 (rows) and leaves all other dimensions untouched, even for rank > 2 data.
  • Inputs with a single row (row vectors, scalars) are returned unchanged because the first dimension is singleton.
  • Numeric, logical, complex, character, string, and cell arrays retain their types and full N-D shapes. All eight integer classes preserve authoritative values and class.
  • Struct, table, timetable, categorical, datetime, duration, and calendar-duration support is not yet implemented.
  • gpuArray inputs execute on the device via the generic flip provider hook (axis = 0); when that hook is unavailable, RunMat gathers once, mirrors the data on the host, and uploads the result so the returned value is still a gpuArray.
  • Dimensions larger than ndims(A) are treated as singleton axes, so flipud never errors when A has rank < 1.
  • Behaviour matches flip(A, 1) exactly; flipud is provided for readability and compatibility with existing MATLAB code.

Does RunMat run flipud on the GPU?

RunMat first tries to execute flipud on the GPU by delegating to the provider’s generic flip implementation with axis 0 (zero-based). If the provider does not implement this hook, RunMat transparently gathers the tensor, performs the vertical flip on the host, and uploads the result back to the device so residency is preserved.

GPU memory and residency

You typically do not need to call gpuArray directly. RunMat’s auto-offload planner keeps tensors on the GPU when profitable and only gathers when a provider lacks the flip hook. Even in that fallback, flipud uploads the flipped result back to the device so subsequent operations remain gpu-resident.

Examples

Reverse Rows of a Matrix

A = [1 2 3; 4 5 6; 7 8 9];
B = flipud(A)

Expected output:

B =
     7     8     9
     4     5     6
     1     2     3

Reverse a Column Vector

col = (1:4)';
rev = flipud(col)

Expected output:

rev =
     4
     3
     2
     1

Flip the First Dimension of a 3-D Tensor

T = reshape(1:24, [3 4 2]);
F = flipud(T)

Expected output:

F(:,:,1) =
     3     6     9    12
     2     5     8    11
     1     4     7    10

F(:,:,2) =
    15    18    21    24
    14    17    20    23
    13    16    19    22

Flip Characters in a Char Array Vertically

C = ['run'; 'mat'];
Cv = flipud(C)

Expected output:

Cv =
    'mat'
    'run'

Preserve Row Vector Orientation

row = 1:5;
same = flipud(row)

Expected output:

same = [1 2 3 4 5]

Keep gpuArray Results on the Device While Flipping Rows

G = gpuArray(rand(8, 8));
H = flipud(G);
isequal(gather(H), flipud(gather(G)))   % illustrative verification

Using flipud with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how flipud changes the result.

Run a small flipud example, explain the result, then change one input and compare the output.

FAQ

Does flipud change row vectors?⌄

No. A row vector has a singleton first dimension, so reversing that axis leaves the data unchanged.

Is flipud the same as calling flip(A, 1)?⌄

Yes. flipud is a convenience wrapper around flip that always targets dimension&nbsp;1 (rows).

Can I apply flipud to N-D tensors?⌄

Absolutely. Only dimension&nbsp;1 is reversed; all other axes keep their original order regardless of rank.

Does flipud support string, character, and cell arrays?⌄

Yes. String arrays reorder their elements, character arrays preserve their character storage, and cell arrays reverse their rows without changing contained values.

What happens on the GPU if there is no flip kernel?⌄

RunMat gathers the tensor once, mirrors it on the CPU, and uploads the result so you still receive a gpuArray.

Does flipud allocate new GPU buffers?⌄

Providers may reuse storage, but the builtin always returns a fresh handle. The simple provider uploads a new buffer.

Is flipud numerically stable?⌄

Yes. The function only reorders elements; values are never modified, so it is numerically stable.

What does flipud do in MATLAB?⌄

— B = flipud(A) returns A with the order of its rows reversed, so B(i, :) = A(end - i + 1, :). The number of columns and every higher-dimension page stays exactly the same.

What's the difference between flipud, fliplr, and flip?⌄

— flipud reverses dimension&nbsp;1 (rows), fliplr reverses dimension&nbsp;2 (columns), and flip(A, dim) reverses any dimension you pick. Modern MATLAB code tends to use flip(A, dim) directly; flipud and fliplr are convenience wrappers kept for readability.

How do I reverse a column vector?⌄

— For a column vector, flipud(v) returns the reversed vector. A dimension-agnostic idiom that works for row or column vectors is v(end:-1:1).

Related Array functions

Shape

blkdiag · cat · circshift · diag · flip · fliplr · horzcat · ipermute · kron · permute · repelem · repmat · reshape · rot90 · squeeze · toeplitz · tril · triu · vertcat

Grouping

accumarray · combinations · discretize · findgroups · groupcounts · grp2idx · splitapply

Sorting Sets

argsort · intersect · ismember · ismembertol · issorted · issortedrows · setdiff · setxor · sort · sortrows · union · unique

Creation

colon · createArray · empty · eye · false · full · inf · linspace · logspace · magic · meshgrid · nan · nchoosek · ndgrid · nonzeros · ones · peaks · perms · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · zeros

Indexing

find · ind2sub · sub2ind

Introspection

iscolumn · isempty · ismatrix · isrow · isscalar · isvector · length · ndims · numel · size

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how flipud is executed, line by line, in Rust.

  • View the source for flipud in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How flipud works
  • Does RunMat run flipud on the GPU?
  • GPU memory and residency
  • Examples
  • Reverse Rows of a Matrix
  • Reverse a Column Vector
  • Flip the First Dimension of a 3-D Tensor
  • Flip Characters in a Char Array Vertically
  • Preserve Row Vector Orientation
  • Keep gpuArray Results on the Device While Flipping Rows
  • Using flipud with coding agents
  • FAQ
  • Related Array functions
  • Shape
  • Grouping
  • Sorting Sets
  • Creation
  • Indexing
  • Introspection
  • Open-source implementation
  • About RunMat