From 24cce762ee72903b03ce8468e3bdfe3fb81f879e Mon Sep 17 00:00:00 2001 From: Andy Ferris Date: Mon, 6 Feb 2017 08:56:16 +1000 Subject: [PATCH] Added doc refs and tests --- base/linalg/conjarray.jl | 21 +++++++++++++++++---- base/linalg/rowvector.jl | 34 ++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/base/linalg/conjarray.jl b/base/linalg/conjarray.jl index a74ec8ad35bce8..d836994cfda849 100644 --- a/base/linalg/conjarray.jl +++ b/base/linalg/conjarray.jl @@ -3,10 +3,23 @@ """ ConjArray(array) -A lazy-view wrapper of an `AbstractArray`, taking the elementwise complex -conjugate. This type is usually constructed (and unwrapped) via the `conj()` -function (or related `ctranspose()`), but currently this is the default behavior -for `RowVector` only. +A lazy-view wrapper of an `AbstractArray`, taking the elementwise complex conjugate. This +type is usually constructed (and unwrapped) via the [`conj`](@ref) function (or related +[`ctranspose`](@ref)), but currently this is the default behavior for `RowVector` only. For +other arrays, the `ConjArray` constructor can be used directly. + +# Examples + +```jldoctest +julia> [1+im, 1-im]' +1×2 RowVector{Complex{Int64},ConjArray{Complex{Int64},1,Array{Complex{Int64},1}}}: + 1-1im 1+1im + +julia> ConjArray([1+im 0; 0 1-im]) +2×2 ConjArray{Complex{Int64},2,Array{Complex{Int64},2}}: + 1-1im 0+0im + 0+0im 1+1im +``` """ immutable ConjArray{T, N, A <: AbstractArray} <: AbstractArray{T, N} parent::A diff --git a/base/linalg/rowvector.jl b/base/linalg/rowvector.jl index 8d1a3ff73609e1..bd8d7f1ba5c306 100644 --- a/base/linalg/rowvector.jl +++ b/base/linalg/rowvector.jl @@ -1,17 +1,15 @@ """ RowVector(vector) -A lazy-view wrapper of an `AbstractVector`, which turns a length-`n` vector into -a `1×n` shaped row vector and represents the transpose of a vector (the elements -are also transposed recursively). This type is usually constructed (and -unwrapped) via the `transpose()` function or `.'` operator (or related -`ctranspose()` or `'` operator). - -By convention, a vector can be multiplied by a matrix on its left (`A * v`) -whereas a row vector can be multiplied by a matrix on its right (such that -`v.' * A = (A.' * v).'`). It differs from a `1×n`-sized matrix by the facts that -its transpose returns a vector and the inner product `v1.' * v2` returns a -scalar, but will otherwise behave similarly. +A lazy-view wrapper of an `AbstractVector`, which turns a length-`n` vector into a `1×n` +shaped row vector and represents the transpose of a vector (the elements are also transposed +recursively). This type is usually constructed (and unwrapped) via the [`transpose`](@ref) +function or `.'` operator (or related [`ctranspose`](@ref) or `'` operator). + +By convention, a vector can be multiplied by a matrix on its left (`A * v`) whereas a row +vector can be multiplied by a matrix on its right (such that `v.' * A = (A.' * v).'`). It +differs from a `1×n`-sized matrix by the facts that its transpose returns a vector and the +inner product `v1.' * v2` returns a scalar, but will otherwise behave similarly. """ immutable RowVector{T,V<:AbstractVector} <: AbstractMatrix{T} vec::V @@ -89,7 +87,19 @@ parent(rowvec::RowVector) = rowvec.vec """ conj(rowvector) -Returns a `ConjArray` lazy view of the input, where each element is conjugated. +Returns a [`ConjArray`](@ref) lazy view of the input, where each element is conjugated. + +### Example + +```jldoctest +julia> v = [1+im, 1-im].' +1×2 RowVector{Complex{Int64},Array{Complex{Int64},1}}: + 1+1im 1-1im + +julia> conj(v) +1×2 RowVector{Complex{Int64},ConjArray{Complex{Int64},1,Array{Complex{Int64},1}}}: + 1-1im 1+1im +``` """ @inline conj(rowvec::RowVector) = RowVector(_conj(rowvec.vec)) @inline conj{T<:Real}(rowvec::RowVector{T}) = rowvec