# Import numpy package
import numpy as np

# Create numpy.array from list
x = np.array([2, 5, 0])
print(x)

x = np.array([[2, 5, 0],
              [3, 5, 1],
              [3, 7, 8]])
print(x)

# Zero matrices
x = np.zeros(3)
print(x)

x = np.zeros((3, 3))
print(x)

# Matrices filled with 1
x = np.ones(3)
print(x)

x = np.ones((3, 3))
print(x)

# Identity matrix
x = np.eye(3)
print(x)

# Ranges
x = np.arange(10)
print(x)

x = np.arange(2, 10, dtype=np.float)
print(x)

x = np.linspace(1.0, 4.0, 10)
print(x)

# Random matrices
x = np.random.rand(3, 3)
print(x)

# Slicing
x = np.random.rand(3, 3)
print(x)
print(x[:, 0])
print(x[1, :])
x[:, 0] = x[:, 1]
print(x)

# Transposition
x = np.random.rand(3, 3)
print(x)
print(x.transpose())

# Save to file
x = np.random.rand(10, 2)
np.savetxt("x.csv", x, delimiter=',', fmt="%.5g")
x = np.loadtxt("x.csv", delimiter=',')
print(x)

# Elementwise operations
a = np.random.rand(3)
b = np.random.rand(3)
print(a)
print(b)
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(np.dot(a, b))

X = np.random.rand(3, 3)

print(X*a)
print(np.dot(X, a))

# Solve linear matrix equation
A = np.random.rand(3, 3)
b = np.random.rand(3)
x = np.linalg.solve(A, b)

print(np.dot(A, x) - b)

# Inverse matrix
A = np.random.rand(3, 3)
Ainv = np.linalg.inv(A)
print(np.dot(A, Ainv))
fd97435baf7d33420edaf6ad7d3c3429f9a0016c
<mask token>

<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
<mask token>
print(x)
print(x[:, 0])
print(x[1, :])
<mask token>
print(x)
<mask token>
print(x)
print(x.transpose())
<mask token>
np.savetxt('x.csv', x, delimiter=',', fmt='%.5g')
<mask token>
print(x)
<mask token>
print(a)
print(b)
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(np.dot(a, b))
<mask token>
print(X * a)
print(np.dot(X, a))
<mask token>
print(np.dot(A, x) - b)
<mask token>
print(np.dot(A, Ainv))

<mask token>
x = np.array([2, 5, 0])
print(x)
x = np.array([[2, 5, 0], [3, 5, 1], [3, 7, 8]])
print(x)
x = np.zeros(3)
print(x)
x = np.zeros((3, 3))
print(x)
x = np.ones(3)
print(x)
x = np.ones((3, 3))
print(x)
x = np.eye(3)
print(x)
x = np.arange(10)
print(x)
x = np.arange(2, 10, dtype=np.float)
print(x)
x = np.linspace(1.0, 4.0, 10)
print(x)
x = np.random.rand(3, 3)
print(x)
x = np.random.rand(3, 3)
print(x)
print(x[:, 0])
print(x[1, :])
x[:, 0] = x[:, 1]
print(x)
x = np.random.rand(3, 3)
print(x)
print(x.transpose())
x = np.random.rand(10, 2)
np.savetxt('x.csv', x, delimiter=',', fmt='%.5g')
x = np.loadtxt('x.csv', delimiter=',')
print(x)
a = np.random.rand(3)
b = np.random.rand(3)
print(a)
print(b)
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(np.dot(a, b))
X = np.random.rand(3, 3)
print(X * a)
print(np.dot(X, a))
A = np.random.rand(3, 3)
b = np.random.rand(3)
x = np.linalg.solve(A, b)
print(np.dot(A, x) - b)
A = np.random.rand(3, 3)
Ainv = np.linalg.inv(A)
print(np.dot(A, Ainv))

import numpy as np
x = np.array([2, 5, 0])
print(x)
x = np.array([[2, 5, 0], [3, 5, 1], [3, 7, 8]])
print(x)
x = np.zeros(3)
print(x)
x = np.zeros((3, 3))
print(x)
x = np.ones(3)
print(x)
x = np.ones((3, 3))
print(x)
x = np.eye(3)
print(x)
x = np.arange(10)
print(x)
x = np.arange(2, 10, dtype=np.float)
print(x)
x = np.linspace(1.0, 4.0, 10)
print(x)
x = np.random.rand(3, 3)
print(x)
x = np.random.rand(3, 3)
print(x)
print(x[:, 0])
print(x[1, :])
x[:, 0] = x[:, 1]
print(x)
x = np.random.rand(3, 3)
print(x)
print(x.transpose())
x = np.random.rand(10, 2)
np.savetxt('x.csv', x, delimiter=',', fmt='%.5g')
x = np.loadtxt('x.csv', delimiter=',')
print(x)
a = np.random.rand(3)
b = np.random.rand(3)
print(a)
print(b)
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(np.dot(a, b))
X = np.random.rand(3, 3)
print(X * a)
print(np.dot(X, a))
A = np.random.rand(3, 3)
b = np.random.rand(3)
x = np.linalg.solve(A, b)
print(np.dot(A, x) - b)
A = np.random.rand(3, 3)
Ainv = np.linalg.inv(A)
print(np.dot(A, Ainv))

# Import numpy package
import numpy as np

# Create numpy.array from list
x = np.array([2, 5, 0])
print(x)

x = np.array([[2, 5, 0],
              [3, 5, 1],
              [3, 7, 8]])
print(x)

# Zero matrices
x = np.zeros(3)
print(x)

x = np.zeros((3, 3))
print(x)

# Matrices filled with 1
x = np.ones(3)
print(x)

x = np.ones((3, 3))
print(x)

# Identity matrix
x = np.eye(3)
print(x)

# Ranges
x = np.arange(10)
print(x)

x = np.arange(2, 10, dtype=np.float)
print(x)

x = np.linspace(1.0, 4.0, 10)
print(x)

# Random matrices
x = np.random.rand(3, 3)
print(x)

# Slicing
x = np.random.rand(3, 3)
print(x)
print(x[:, 0])
print(x[1, :])
x[:, 0] = x[:, 1]
print(x)

# Transposition
x = np.random.rand(3, 3)
print(x)
print(x.transpose())

# Save to file
x = np.random.rand(10, 2)
np.savetxt("x.csv", x, delimiter=',', fmt="%.5g")
x = np.loadtxt("x.csv", delimiter=',')
print(x)

# Elementwise operations
a = np.random.rand(3)
b = np.random.rand(3)
print(a)
print(b)
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(np.dot(a, b))

X = np.random.rand(3, 3)

print(X*a)
print(np.dot(X, a))

# Solve linear matrix equation
A = np.random.rand(3, 3)
b = np.random.rand(3)
x = np.linalg.solve(A, b)

print(np.dot(A, x) - b)

# Inverse matrix
A = np.random.rand(3, 3)
Ainv = np.linalg.inv(A)
print(np.dot(A, Ainv))