Vous êtes sur la page 1sur 3

Octave-Forge: CPPQuickReference

http://209.85.175.104/search?q=cache:7WKjLMsp...

T his is Google's c ac he of http://w iki.octav e.org/w iki.pl?CPPQuickReference. It is a snapshot of the page as it appeared on 22 Sep 2008 12:17:34 GMT . T he current page c ould have c hanged in the meantime. Learn more T hese searc h terms are highlighted: octav e c++ column v ector size Text-only v ersion

Octave Wiki | RecentChanges

CPPQuickReference
This is a table of matrix operations commonly performed in Octave and their equivalents in C++ when using the octave libraries.

Matrix Operations
Operation Octave A+B add A-B subtract matrix A*B multiplication element A.*B multiplication A./B element division A' transpose* select element m,n A(m,n) of A** select row N of A** A(N,:) select column N of A(:,N) A** extract submatrix A(a:b,c:d) of A absolute value of A abs(A) comparison to A>2 scalar***
A<2 A==2 A~=2 A>=2 A<=2

C++
A+B A-B A*B

product(A,B) quotient(A,B) A.transpose() A(m-1,n-1) A.row(N-1) A.column(N-1)

A.extract(a-1,c-1,b-1,d-1) A.abs() mx_el_gt(A,2) mx_el_lt(A,2) mx_el_eq(A,2) mx_el_ne(A,2) mx_el_ge(A,2) mx_el_le(A,2)

1 of 3

Monday 29,September,2008 04:28 PM

Octave-Forge: CPPQuickReference

http://209.85.175.104/search?q=cache:7WKjLMsp...

matrix of zeros matrix of ones identity matrix inverse of A pseudoinverse of A diagonal elements of A column vector row vector check for Inf or NaN stack two matrices vertically uniform random matrix normal random matrix sum squares of columns sum along columns sum along rows product along columns product along rows cumsum along columns cumsum along rows cumproduct along columns cumproduct along rows number of rows number of columns Notes:

A=zeros(m,n) A=ones(m,n) eye(N) inv(A) pinv(A) diag(A) A(:) A(:)'

A.fill(0.0) A.fill(1.0) identity_matrix(N,N) A.inverse() A.pseudo_inverse() A.diag() ColumnVector(A.reshape (dim_vector(A.length()))) RowVector(A.reshape (dim_vector(A.length())))

any(~isfinite(A)) A.any_element_is_inf_or_nan()

A=[B;C]

B.stack(C) octave_rand::distribution("uniform"); octave_rand::matrix(a,b) octave_rand::distribution("normal"); octave_rand::matrix(a,b) A.sumsq() A.sum(0) A.sum(1) A.prod(0) A.prod(1) A.cumsum(0)

rand(a,b)

randn(a,b)

sumsq(A) sum(A,1) sum(A,2) prod(A,1) prod(A,2) cumsum(A,1)

cumsum(A,2)

A.cumsum(1)

cumprod(A,1)

A.cumprod(0)

cumprod(A,2) size(A,1) size(A,2)

A.cumprod(1) A.rows() A.cols()

*Transpose, addition, and multiplication operations also apply to RowVector, ComplexRowVector, ColumnVector, and ComplexColumnVector data types
2 of 3 Monday 29,September,2008 04:28 PM

Octave-Forge: CPPQuickReference

http://209.85.175.104/search?q=cache:7WKjLMsp...

when the dimensions are in agreement. **The difference is due to the fact that arrays are zero-based in C++, but one-based in Octave. **The names of Octave internal functions, such as mx_el_gt, are not documented and are subject to change. Functions such as mx_el_gt may eventually be available at both the scripting level and in C++ under more common names such as gt.

Complex Matrix Operations


Operation Octave conjugate tranpose A' C++
A.hermitian()

Octave Class Reference


A recent class reference generated by doxygen is at http://pareto.uab.es/mcreel/OctaveClassReference /html/index.html CategoryExternal Octave Wiki | RecentChanges Edit text of this page | View other revisions Last edited 2006-05-26 3:05 UTC (diff) Search: Go! Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation

3 of 3

Monday 29,September,2008 04:28 PM