R/055_atoms_affine_bmat.R

Defines functions bmat

Documented in bmat

#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/atoms/affine/bmat.R
#####

## CVXPY SOURCE: atoms/affine/bmat.py
## bmat -- construct a block matrix from a list of lists of expressions

#' Construct a Block Matrix
#'
#' Takes a list of lists. Each internal list is stacked horizontally.
#' The internal lists are stacked vertically.
#'
#' @param block_lists A list of lists of Expression objects (or numerics).
#'   Each inner list forms one block row.
#' @returns An Expression representing the block matrix.
#' @export
bmat <- function(block_lists) {
  if (!is.list(block_lists) || length(block_lists) == 0L) {
    cli_abort("{.fn bmat} requires a non-empty list of lists.")
  }
  row_blocks <- lapply(block_lists, function(blocks) {
    if (!is.list(blocks) || length(blocks) == 0L) {
      cli_abort("Each element of {.fn bmat} input must be a non-empty list.")
    }
    do.call(HStack, blocks)
  })
  do.call(VStack, row_blocks)
}

Try the CVXR package in your browser

Any scripts or data that you put into this service are public.

CVXR documentation built on March 6, 2026, 9:10 a.m.