compute the value of x in the equation ax = b for real-凯发k8网页登录
compute the value of x in the equation ax = b for real-valued matrices using qr decomposition
since r2019b
libraries:
fixed-point designer hdl support /
matrices and linear algebra /
linear system solvers
description
the real burst matrix solve using qr decomposition block solves the system of linear equations ax = b using qr decomposition, where a and b are real-valued matrices. to compute x = a-1, set b to be the identity matrix.
when regularization parameter is nonzero, the
real burst matrix solve using qr decomposition block computes the matrix
solution of real-valued where λ is the regularization parameter,
a is an m-by-n matrix,
p is the number of columns in b,
in =
eye(n)
, and
0n,p =
zeros(n,p)
.
examples
ports
input
a(i,:) — rows of real matrix a
vector
rows of real matrix a, specified as a vector. a is an m-by-n matrix where m ≥ 2 and m ≥ n. if b is single or double, a must be the same data type as b. if a is a fixed-point data type, a must be signed, use binary-point scaling, and have the same word length as b. slope-bias representation is not supported for fixed-point data types.
data types: single
| double
| fixed point
b(i,:) — rows of real matrix b
vector
rows of real matrix b, specified as a vector. b is an m-by-p matrix where m ≥ 2. if a is single or double, b must be the same data type as a. if b is a fixed-point data type, b must be signed, use binary-point scaling, and have the same word length as a. slope-bias representation is not supported for fixed-point data types.
data types: single
| double
| fixed point
validin — whether inputs are valid
boolean
scalar
whether inputs are valid, specified as a boolean scalar. this control signal
indicates when the data from the a(i,:)
and
b(i,:)
input ports are valid. when this value is 1
(true
) and the value at ready
is 1
(true
), the block captures the values on the
a(i,:)
and b(i,:)
input ports. when this
value is 0 (false
), the block ignores the input samples.
after sending a true
validin
signal, there may be some delay before
ready
is set to false
. to ensure all data is
processed, you must wait until ready
is set to
false
before sending another true
validin
signal.
data types: boolean
restart — whether to clear internal states
boolean
scalar
whether to clear internal states, specified as a boolean scalar. when this value
is 1 (true
), the block stops the current calculation and clears all
internal states. when this value is 0 (false
) and the
validin
value is 1 (true
), the block begins
a new subframe.
data types: boolean
output
x(i,:) — rows of matrix x
scalar | vector
rows of the matrix x, returned as a scalar or vector.
data types: single
| double
| fixed point
validout — whether output data is valid
boolean
scalar
whether the output data is valid, returned as a boolean scalar. this control
signal indicates when the data at the output port x(i,:)
is
valid. when this value is 1 (true
), the block has successfully
computed a row of matrix x. when this value is 0
(false
), the output data is not valid.
data types: boolean
ready — whether block is ready
boolean
scalar
whether the block is ready, returned as a boolean scalar. this control signal
indicates when the block is ready for new input data. when this value is 1
(true
) and the validin
value is 1
(true
), the block accepts input data in the next time step. when
this value is 0 (false
), the block ignores input data in the next
time step.
after sending a true
validin
signal, there may be some delay before
ready
is set to false
. to ensure all data is
processed, you must wait until ready
is set to
false
before sending another true
validin
signal.
data types: boolean
parameters
number of rows in matrices a and b — number of rows in matrices a and b
4
(default) | positive integer-valued scalar
number of rows in input matrices a and b, specified as a positive integer-valued scalar.
programmatic use
block parameter:
m |
type: character vector |
values: positive integer-valued scalar |
default:
4 |
number of columns in matrix a — number of columns in matrix a
4
(default) | positive integer-valued scalar
number of columns in input matrix a, specified as a positive integer-valued scalar.
programmatic use
block parameter:
n |
type: character vector |
values: positive integer-valued scalar |
default:
4 |
number of columns in matrix b — number of columns in matrix b
1
(default) | positive integer-valued scalar
number of columns in input matrix b, specified as a positive integer-valued scalar.
programmatic use
block parameter:
p |
type: character vector |
values: positive integer-valued scalar |
default:
1 |
regularization parameter — regularization parameter
0 (default) | nonnegative scalar
regularization parameter, specified as a nonnegative scalar. small, positive values of the regularization parameter can improve the conditioning of the problem and reduce the variance of the estimates. while biased, the reduced variance of the estimate often results in a smaller mean squared error when compared to least-squares estimates.
programmatic use
block parameter:
regularizationparameter |
type: character vector |
values: positive integer-valued scalar |
default:
0 |
output datatype — data type of the output matrix x
fixdt(1,18,14)
(default) | double
| single
| fixdt(1,16,0)
|
data type of the output matrix x, specified as
fixdt(1,18,14)
, double
,
single
, fixdt(1,16,0)
, or as a user-specified
data type expression. the type can be specified directly, or expressed as a data type
object such as simulink.numerictype
.
programmatic use
block parameter:
outputtype |
type: character vector |
values:
'fixdt(1,18,14)' | 'double' |
'single' | 'fixdt(1,16,0)' |
'' |
default:
'fixdt(1,18,14)' |
tips
use fixed.getmatrixsolvemodel(a,b)
to generate a template model
containing a real burst matrix solve using qr decomposition block for
real-valued input matrices a
and b
.
algorithms
choosing the implementation method
partial-systolic implementations prioritize speed of computations over space constraints, while burst implementations prioritize space constraints at the expense of speed of the operations. the following table illustrates the tradeoffs between the implementations available for matrix decompositions and solving systems of linear equations.
implementation | ready | latency | area |
---|---|---|---|
systolic | c | o(n) | o(mn2) |
partial-systolic | c | o(m) | o(n2) |
partial-systolic with forgetting factor | c | o(n) | o(n2) |
burst | o(n) | o(mn2) | o(n) |
where c is a constant proportional to the word length of the data, m is the number of rows in matrix a, and n is the number of columns in matrix a.
for additional considerations in selecting a block for your application, see .
synchronous vs asynchronous implementation
the matrix solve using qr decomposition blocks operate synchronously. these blocks first decompose the input a and b matrices into r and c matrices using a qr decomposition block. then, a back substitute block computes rx = c. the input a and b matrices propagate through the system in parallel, in a synchronized way.
the matrix solve using q-less qr decomposition blocks operate asynchronously. first, q-less qr decomposition is performed on the input a matrix and the resulting r matrix is put into a buffer. then, a forward backward substitution block uses the input b matrix and the buffered r matrix to compute r'rx = b. because the r and b matrices are stored separately in buffers, the upstream q-less qr decomposition block and the downstream forward backward substitute block can run independently. the forward backward substitute block starts processing when the first r and b matrices are available. then it runs continuously using the latest buffered r and b matrices, regardless of the status of the q-less qr decomposition block. for example, if the upstream block stops providing a and b matrices, the forward backward substitute block continues to generate the same output using the last pair of r and b matrices.
the burst (asynchronous) matrix solve using q-less qr decomposition blocks are available in both synchronous and asynchronous operation variants, as denoted by the block name.
amba axi handshake process
this block uses the amba axi handshake protocol [1]. the valid/ready
handshake process is used to transfer data and control information. this two-way control mechanism allows both the manager and subordinate to control the rate at which information moves between manager and subordinate. a valid
signal indicates when data is available. the ready
signal indicates that the block can accept the data. transfer of data occurs only when both the valid
and ready
signals are high.
block timing
the burst matrix solve using qr decomposition blocks accept and process a and b matrices row by row synchronously. after accepting m rows, the block outputs the x matrix row by row continuously. the matrix is output from the first row to the last row.
for example, assume that the input a and b matrices
are 3-by-3. additionally assume that validin
asserts before
ready
, meaning that the upstream data source is faster than the qr
decomposition.
in the figure,
a1r1
is the first row of the first a matrix,x1r3
is the third row of the first x matrix, and so on.validin
toready
— from a successful row input to the block being ready to accept the next row within one matrix.last row
validin
tovalidout
— from the last row input to the block starting to output the solution.last row
validin
to new matrix ready — from the block starting to output the solution to the block ready to accept the next matrix input.
the burst matrix solve using q-less qr decomposition blocks accept and process a and b matrices row by row synchronously. after accepting m rows, the block outputs the x matrix row by row continuously. the matrix is output from the first row to the last row.
for example, assume that the input a and b matrices
are 3-by-3. additionally assume that validin
asserts before
ready
, meaning that the upstream data source is faster than the qr
decomposition.
in the figure,
a1r1
is the first row of the first a matrix,x1r3
is the third row of the first x matrix, and so on.validin
toready
— from a successful row input to the block being ready to accept the next row within one matrix.last row
validin
tovalidout
— from the last row input to the block starting to output the solution.last row
validin
to new matrix ready — from the block starting to output the solution to the block ready to accept the next matrix input.
the following table provides details of the timing for the burst matrix solve using qr decomposition and burst matrix solve using q-less qr decomposition blocks.
block | operation | validin to ready (cycles) | last row validin to validout
(cycles) | last row validin to new matrix ready (cycles) |
---|---|---|---|---|
real burst matrix solve using qr decomposition | synchronous | (wl 5)*n 2 | (wl 5)*n 3.5*n2 n*(nextpow2(wl) wl 8.5) 3 | (wl 5)*n 3.5*(n - 1)2 (n - 1)(nextpow2(wl) wl 8.5) 3 |
synchronous | (wl*2 11)*n 2 | (wl*2 11)*n 3.5*n2 n*(nextpow2(wl) wl 8.5) 3 | (wl*2 11)*n 3.5*(n-1)2 (n-1)(nextpow2(wl) wl 8.5) 3 | |
synchronous | (wl 5)*n 2 | 7*n2 27*n 6 3*n*wl 2*n*nextpow2(wl) | 7*n2 27*n 6 3*n*wl 2*n*nextpow2(wl) min(m,n) | |
synchronous | (wl*2 11)*n 2 | 7*22 33*n 6 4*n*wl 2*n*nextpow2(wl) | 7*n2 33*n 6 4*n*wl 2*n*nextpow2(wl) min(m,n) |
in the table, m represents the number of rows in matrix a, and n is the number of columns in matrix a. wl represents the word length of a.
if the data type of a is fixed point, then wl is the word length.
if the data type of a is double, then wl is 53.
if the data type of a is single, then wl is 24.
hardware resource utilization
this block supports hdl code generation using the simulink® hdl workflow advisor. for an example, see (hdl coder) and implement digital downconverter for fpga (dsp hdl toolbox).
this example data was generated by synthesizing the block on a xilinx® zynq® ultrascale™ rfsoc zcu111 evaluation board. the synthesis tool was vivado® v.2020.2 (win64).
the following parameters were used for synthesis.
block parameters:
m = 16
n = 16
p = 1
matrix a dimension: 16-by-16
matrix b dimension: 16-by-1
input data type:
sfix16_en14
target frequency: 300 mhz
the following tables show the post place-and-route resource utilization results and timing summary, respectively.
resource | usage | available | utilization (%) |
---|---|---|---|
clb luts | 9629 | 425280 | 2.26 |
clb registers | 10005 | 850560 | 1.18 |
dsps | 2 | 4272 | 0.05 |
block ram tile | 0 | 1080 | 0.00 |
uram | 0 | 80 | 0.00 |
value | |
---|---|
requirement | 3.3333 ns |
data path delay | 2.893 ns |
slack | 0.421 ns |
clock frequency | 343.37 mhz |
references
[1] "amba axi and ace protocol specification version e."
extended capabilities
c/c code generation
generate c and c code using simulink® coder™.
slope-bias representation is not supported for fixed-point data types.
hdl code generation
generate verilog and vhdl code for fpga and asic designs using hdl coder™.
hdl coder™ provides additional configuration options that affect hdl implementation and synthesized logic.
this block has one default hdl architecture.
general | |
---|---|
constrainedoutputpipeline | number of registers to place at
the outputs by moving existing delays within your design. distributed
pipelining does not redistribute these registers. the default is
|
inputpipeline | number of input pipeline stages
to insert in the generated code. distributed pipelining and constrained
output pipelining can move these registers. the default is
|
outputpipeline | number of output pipeline stages
to insert in the generated code. distributed pipelining and constrained
output pipelining can move these registers. the default is
|
supports fixed-point data types only.
version history
introduced in r2019br2022a: support for tikhonov regularization parameter
the real burst matrix solve using qr decomposition block now supports the tikhonov regularization parameter.
see also
blocks
- | |
functions
topics
matlab 命令
您点击的链接对应于以下 matlab 命令:
请在 matlab 命令行窗口中直接输入以执行命令。web 浏览器不支持 matlab 命令。
select a web site
choose a web site to get translated content where available and see local events and offers. based on your location, we recommend that you select: .
you can also select a web site from the following list:
how to get best site performance
select the china site (in chinese or english) for best site performance. other mathworks country sites are not optimized for visits from your location.
americas
- (español)
- (english)
- (english)
europe
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
asia pacific
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)