MPIBlockMatrix

(类来自 pyomo.contrib.pynumero.sparse.mpi_block_matrix)

class pyomo.contrib.pynumero.sparse.mpi_block_matrix.MPIBlockMatrix(nbrows, nbcols, rank_ownership, mpi_comm, assert_correct_owners=False)[source]

基础类:BaseBlockMatrix

并行结构化矩阵接口

_rank_owner

二维数组,表示每个块的处理器的所有权。一个块可以由单个处理器或所有处理器拥有。由所有处理器拥有的块的所有权为-1。由单个处理器拥有的块具有所有权等级,其中等级=MPI.COMM_WORLD.Get_rank()

Type:

numpy.ndarray

_mpiw

来自MPI空间的通信器。通常是MPI.COMM_WORLD

Type:

MPI.Comm

_block_matrix

内部块矩阵。属于此处理器的块存储在_block_matrix中。

Type:

BlockMatrix

_owned_mask

表示一个块是否属于此处理器的2D数组。虽然_rank_owner告诉每个块由哪个处理器拥有,但_owned_mask告诉一个块是否由此处理器拥有。由所有人拥有的块(即所有权 = -1)在_owned_mask中为True。

Type:

numpy.ndarray 布尔型

_unique_owned_mask

表示一个块是否属于此处理器的2D数组。虽然_rank_owner告诉每个块由哪个处理器拥有,_unique_owned_mask则告诉一个块是否由此处理器拥有。由所有人拥有的块(即所有权 = -1)在_unique_owned_mask中为False。

Type:

numpy.ndarray 布尔型

Parameters:
  • nbrows (int) – 矩阵中的块行数

  • nbcols (int) – 矩阵中的块列数

  • rank_ownership (array_like) – 指定矩阵中每个块的进程所有者等级的整数二维数组。对于由所有进程拥有的块,等级为-1。None的块应由所有进程拥有。

  • mpi_comm (MPI通信器)

  • assert_correct_owners (bool) – 如果为True,则将执行检查以确保处理器所有者一致。此检查需要通信。如果为False,则跳过此检查。

__init__(nbrows, nbcols, rank_ownership, mpi_comm, assert_correct_owners=False)[source]

方法

__init__(nbrows, nbcols, rank_ownership, ...)

block_shapes()

返回此BlockMatrix中块的形状列表

broadcast_block_sizes()

将所有块的大小发送到所有处理器。

col_block_sizes([copy])

返回带有列块大小的数组

coo_data()

copy()

复制此MPIBlockMatrix

copy_structure()

复制此MPIBlockMatrix的结构。

diagonal([k])

dot(other)

普通点积

fromBlockMatrix(block_matrix, ...[, ...])

从blockmatrix创建一个并行的MPIBlockMatrix

get_block(row, col)

get_block_column_index(index)

从矩阵列索引返回块列索引。

get_block_mask([copy])

get_block_row_index(index)

从矩阵行索引返回块行索引。

get_col_size(col)

get_row_size(row)

getcol(j)

返回列j的MPIBlockVector

getrow(i)

返回第i列的MPIBlockVector

has_undefined_col_sizes()

指示矩阵是否具有未定义维度的块列

has_undefined_row_sizes()

指示矩阵是否具有未定义维度的块行

is_col_size_defined(col[, this_process_only])

is_empty_block(idx, jdx[, this_process_only])

指示一个块是否为空

is_row_size_defined(row[, this_process_only])

mean([axis, dtype, out])

nonzero()

reset_bcol(jdx)

将选定列中的所有块重置为无(0个非零条目)

reset_brow(idx)

将选定行中的所有块重置为无(0个非零条目)

row_block_sizes([copy])

返回包含行块大小的数组

set_block(row, col, value)

set_col_size(col, size)

set_row_size(row, size)

setdiag(values[, k])

sum([axis, dtype, out])

to_local_array()

此方法仅用于测试/调试

toarray()

返回此矩阵的密集ndarray表示。

tobsr([blocksize, copy])

tocoo()

将此矩阵转换为coo_matrix格式。

tocsc()

将此矩阵转换为csc格式。

tocsr()

将此矩阵转换为csr格式。

todia([copy])

tolil([copy])

tostring([order])

transpose([axes, copy])

反转块矩阵的维度。

属性

T

转置矩阵

bshape

返回矩阵的块形状的元组

mpi_comm

返回MPI通信器

nnz

返回此矩阵中非零值的总数

owned_blocks

返回此处理器拥有的块的索引列表。

ownership_mask

返回一个布尔二维数组,指示哪些块由该处理器拥有

rank_ownership

返回指定每个块所属进程等级的2D数组。

shape

返回包含总行数和总列数的元组

shared_blocks

返回所有处理器共享的块的索引的2元组列表

成员文档

block_shapes()[source]

返回此BlockMatrix中块的形状列表

注释

对于一个具有2个块行和2个块列的MPIBlockMatrix 此方法返回[[Block_00.shape, Block_01.shape],[Block_10.shape, Block_11.shape]]

Return type:

list

broadcast_block_sizes()[source]

将所有块的大小发送给所有处理器。调用此方法后,MPIBlockMatrix 知道其所有行和列的维度。在使用 MPIBlockMatrix 运行任何操作之前,必须调用此方法。

col_block_sizes(copy=True)[source]

返回带有列块大小的数组

Parameters:

复制 (bool) – 如果为False,则返回存储列块大小的内部数组而不进行复制。 将copy设置为False是有风险的,应极其谨慎地进行。

Return type:

numpy.ndarray

copy()[source]

复制此MPIBlockMatrix

Return type:

MPIBlockMatrix

copy_structure()[source]

复制此MPIBlockMatrix的结构。这提供了此MPIBlockMatrix中每个块的轻量级副本。结果矩阵中的块具有与原始矩阵相同的形状,但不具有相同的非零元素数量。

Return type:

MPIBlockMatrix

dot(other)[source]

普通点积

static fromBlockMatrix(block_matrix, rank_ownership, mpi_comm, assert_correct_owners=False)[source]

从blockmatrix创建一个并行的MPIBlockMatrix

Parameters:
  • block_matrix (BlockMatrix) – 用于创建MPIBlockMatrix的块矩阵

  • rank_ownership (array_like) – 二维数组,表示每个处理器的块所有权。一个块可以由单个处理器或所有处理器拥有。由所有处理器拥有的块的值为-1。由单个处理器拥有的块的值为该处理器的rank,其中rank=MPI.COMM_WORLD.Get_rank()

  • mpi_comm (MPI通信器) – 一个MPI通信器。通常是MPI.COMM_WORLD

get_block_column_index(index)[source]

从矩阵列索引返回块列索引。

Parameters:

index (int) – 列索引

Return type:

int

get_block_row_index(index)[源代码]

从矩阵行索引返回块行索引。

Parameters:

index (int) – 行索引

Return type:

int

getcol(j)[source]

返回列j的MPIBlockVector

Parameters:

j (int) – 列索引

Return type:

pyomo.contrib.pynumero.sparse MPIBlockVector

getrow(i)[source]

返回第i列的MPIBlockVector

Parameters:

i (int) – 行索引

Return type:

pyomo.contrib.pynumero.sparse MPIBlockVector

has_undefined_col_sizes()[source]

指示矩阵是否具有未定义维度的块列

Return type:

bool

has_undefined_row_sizes()[source]

指示矩阵是否具有未定义维度的块行

Return type:

bool

is_empty_block(idx, jdx, this_process_only=True)[source]

指示一个块是否为空

Parameters:
  • idx (int) – 块行索引

  • jdx (int) – 块列索引

Return type:

布尔值

reset_bcol(jdx)[source]

将选定列中的所有块重置为无(0个非零条目)

Parameters:

jdx (integer) – 要重置的列索引

Return type:

reset_brow(idx)[source]

将选定行中的所有块重置为无(0个非零条目)

Parameters:

idx (整数) – 要重置的行索引

Return type:

row_block_sizes(copy=True)[source]

返回包含行块大小的数组

Parameters:

复制 (bool) – 如果为 False,则返回存储行块大小的内部数组而不进行复制。 将 copy 设置为 False 是有风险的,应极其谨慎地进行。

Return type:

numpy.ndarray

to_local_array()[source]

此方法仅用于测试/调试

Returns:

结果

Return type:

np.ndarray

toarray()[source]

返回此矩阵的密集ndarray表示。

Returns:

arr – 一个具有相同形状并包含由块矩阵表示的相同数据的数组。

Return type:

ndarray,二维

tocoo()[source]

将此矩阵转换为coo_matrix格式。

Return type:

coo_matrix

tocsc()[source]

将此矩阵转换为csc格式。

Return type:

csc_matrix

tocsr()[source]

将此矩阵转换为csr格式。

Return type:

csr_matrix

transpose(axes=None, copy=True)[source]

反转块矩阵的维度。

Parameters:
  • axes (None, optional) – 此参数仅出于NumPy兼容性原因存在于签名中。除了默认值外,不要传递任何内容。

  • copy (bool) – 这个参数在签名中仅出于与scipy兼容的原因。不要传入默认值以外的任何内容。

Return type:

维度反转的MPIBlockMatrix

property T

转置矩阵

property bshape

返回矩阵的块形状的元组

property mpi_comm

返回MPI通信器

property nnz

返回此矩阵中非零值的总数

property owned_blocks

返回此处理器拥有的块的索引列表。

property ownership_mask

返回一个布尔二维数组,指示哪些块由该处理器拥有

property rank_ownership

返回一个二维数组,指定每个块所属的进程等级。如果一个块由所有进程拥有,则ownership=-1。

property shape

返回包含总行数和总列数的元组

property shared_blocks

返回所有处理器共享的块的索引的2元组列表