17 lines
371 B
Julia
17 lines
371 B
Julia
|
# https://cs.pwr.edu.pl/zielinski/lectures/scna/hilb.jl
|
||
|
function hilb(n::Int)
|
||
|
# Function generates the Hilbert matrix A of size n,
|
||
|
# A (i, j) = 1 / (i + j - 1)
|
||
|
# Inputs:
|
||
|
# n: size of matrix A, n>=1
|
||
|
#
|
||
|
#
|
||
|
# Usage: hilb(10)
|
||
|
#
|
||
|
# Pawel Zielinski
|
||
|
if n < 1
|
||
|
error("size n should be >= 1")
|
||
|
end
|
||
|
return [1 / (i + j - 1) for i in 1:n, j in 1:n]
|
||
|
end
|