Here are the examples of the python api numpy.transpose taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3194 Examples
5
Source : test_tensor_sum.py
with MIT License
from alibaba
with MIT License
from alibaba
def test_transpose(self):
axesA = (2, 4, 0, 1, 3)
axesB = (3, 4, 1, 0, 2)
axesC = (3, 0, 1, 2, 4)
axes_ = (1, 3, 0, 4, 2)
c = (self.a % axesA
+ self.b % axesB
+ self.c % axesC) % axes_
data = numpy.transpose(numpy.transpose(self.a.contract(), axesA)
+ numpy.transpose(self.b.contract(), axesB)
+ numpy.transpose(self.c.contract(), axesC), axes_)
self.assertTrue(numpy.allclose(c.contract(), data))
def test_add_and_remove_term(self):
3
Source : LinearRegression_NormalEquation.py
with MIT License
from 0xPrateek
with MIT License
from 0xPrateek
def normalequation(x,y):
xt = np.transpose(x)
theta = np.linalg.inv(xt*x)*(np.transpose(x)*y)
return theta
def cost_function(x,y,theta0,theta1): # This function is used for calculating Mean squared error or for minimization of cost function value.
3
Source : prep_noise.py
with MIT License
from a-n-rose
with MIT License
from a-n-rose
def wave2stft(np_array,sr):
stft = librosa.stft(np_array,hop_length=int(0.01*sr),n_fft=int(0.025*sr))
stft = np.transpose(stft)
return stft
def get_energy(stft):
3
Source : prep_noise.py
with MIT License
from a-n-rose
with MIT License
from a-n-rose
def samps2stft(y, sr):
if len(y)%2 != 0:
y = y[:-1]
#print("shape of samples: {}".format(y.shape))
stft = librosa.stft(y)
#print("shape of stft: {}".format(stft.shape))
stft = np.transpose(stft)
#print("transposed shape: {}".format(stft.shape))
return stft
def stft2samps(stft,len_origsamp):
3
Source : prep_noise.py
with MIT License
from a-n-rose
with MIT License
from a-n-rose
def stft2samps(stft,len_origsamp):
#print("shape of stft: {}".format(stft.shape))
istft = np.transpose(stft.copy())
##print("transposed shape: {}".format(istft.shape))
samples = librosa.istft(istft,length=len_origsamp)
return samples
def stft2power(stft_matrix):
3
Source : rednoise_fun.py
with MIT License
from a-n-rose
with MIT License
from a-n-rose
def wave2stft(wavefile):
y, sr = librosa.load(wavefile)
if len(y)%2 != 0:
y = y[:-1]
stft = librosa.stft(y)
stft = np.transpose(stft)
return stft, y, sr
def stft2wave(stft,len_origsamp):
3
Source : rednoise_fun.py
with MIT License
from a-n-rose
with MIT License
from a-n-rose
def stft2wave(stft,len_origsamp):
istft = np.transpose(stft.copy())
samples = librosa.istft(istft,length=len_origsamp)
return samples
def stft2power(stft_matrix):
3
Source : analyse_audio.py
with MIT License
from a-n-rose
with MIT License
from a-n-rose
def wave2stft(wavefile):
y, sr = librosa.load(wavefile)
if len(y)%2 != 0:
y = y[:-1]
stft = librosa.stft(y)
stft = np.transpose(stft)
return stft, y, sr
def wave2stft_long(wavefile):
3
Source : analyse_audio.py
with MIT License
from a-n-rose
with MIT License
from a-n-rose
def wave2stft_long(wavefile):
y, sr = librosa.load(wavefile)
if len(y)%2 != 0:
y = y[:-1]
stft = librosa.stft(y,hop_length=int(interval*sr),n_fft=int(0.256*sr))
stft = np.transpose(stft)
return stft, y, sr
def stft2wave(stft,len_origsamp):
3
Source : analyse_audio.py
with MIT License
from a-n-rose
with MIT License
from a-n-rose
def stft2wave(stft,len_origsamp):
sr=22050
istft = np.transpose(stft.copy())
samples = librosa.istft(istft,length=len_origsamp)
return samples
def stft2power(stft_matrix):
3
Source : compare_signals.py
with MIT License
from a-n-rose
with MIT License
from a-n-rose
def long_term_info(y,sr):
interval = 0.01
window = 0.256
start_stft = time.time()
stft = librosa.stft(y,hop_length=int(interval*sr),n_fft=int(window*sr))
end_stft = time.time()
stft = np.transpose(stft)
power = np.abs(stft)**2
start_pitch = time.time()
pitch, mag = librosa.piptrack(y=y,sr=sr,hop_length=int(interval*sr),n_fft=int(window*sr))
end_pitch = time.time()
duration_stft = end_stft - start_stft
duration_pitch = end_pitch - start_pitch
pitch = np.transpose(pitch)
return stft,power,pitch
def clip_around_sounds(sound_type,stft,samples_length,energy_length,start_index,end_index,sr):
3
Source : plot_double_func_with_theory.py
with MIT License
from a-norcliffe
with MIT License
from a-norcliffe
def run_ode(x):
z0 = [start[x], 0]
z_arr = integrate.odeint(derivatives, z0, times)
z_arr = np.transpose(z_arr)
x_arr = z_arr[0]
a_arr = z_arr[1]
np.save(filename+names[x]+'_theory_x.npy', x_arr)
np.save(filename+names[x]+'_theory_a.npy', a_arr)
run_ode(0)
3
Source : custom_transforms.py
with MIT License
from AaltoML
with MIT License
from AaltoML
def __call__(self, images, intrinsics):
tensors = []
for im in images:
# put it from HWC to CHW format
im = np.transpose(im, (2, 0, 1))
# handle numpy array
#tensors.append(torch.from_numpy(im).float()/255)
tensors.append(torch.from_numpy(im).float())
return tensors, intrinsics
3
Source : autoencoder_diabimmune.py
with MIT License
from aametwally
with MIT License
from aametwally
def import_data(InputFile):
df = pd.read_csv(InputFile, sep=",", index_col=0)
features = list(df.index)
samples = list(df)
data = np.transpose(df.as_matrix())
return data, features, samples
def generate_metadata(samples, MetadataFile):
3
Source : util.py
with BSD 2-Clause "Simplified" License
from AAnoosheh
with BSD 2-Clause "Simplified" License
from AAnoosheh
def tensor2im(image_tensor, imtype=np.uint8):
image_numpy = image_tensor[0].cpu().float().numpy()
image_numpy = (np.transpose(image_numpy, (1, 2, 0)) + 1) / 2.0 * 255.0
if image_numpy.shape[2] < 3:
image_numpy = np.dstack([image_numpy]*3)
return image_numpy.astype(imtype)
def gkern_2d(size=5, sigma=3):
3
Source : model.py
with MIT License
from Abhishek-Doshi
with MIT License
from Abhishek-Doshi
def findCosineSimilarity(source_representation, test_representation):
a = np.matmul(np.transpose(source_representation), test_representation)
b = np.sum(np.multiply(source_representation, source_representation))
c = np.sum(np.multiply(test_representation, test_representation))
return (a / (np.sqrt(b) * np.sqrt(c)))
def findCosineDifference(source_representation, test_representation):
3
Source : model.py
with MIT License
from Abhishek-Doshi
with MIT License
from Abhishek-Doshi
def findCosineDifference(source_representation, test_representation):
a = np.matmul(np.transpose(source_representation), test_representation)
b = np.sum(np.multiply(source_representation, source_representation))
c = np.sum(np.multiply(test_representation, test_representation))
return 1 - (a / (np.sqrt(b) * np.sqrt(c)))
def findEuclideanDistance(source_representation, test_representation):
3
Source : train.py
with MIT License
from ace19-dev
with MIT License
from ace19-dev
def display_data(image):
# display image to verify
image = image.numpy()
image = np.transpose(image, (0, 2, 3, 1))
# # assets not np.any(np.isnan(image))
n_batch = image.shape[0]
# n_view = train_batch_xs.shape[1]
for i in range(n_batch):
img = image[i]
# scipy.misc.toimage(img).show() Or
img = cv2.cvtColor(img.astype(np.uint8), cv2.COLOR_BGR2RGB)
cv2.imwrite('/home/ace19/Pictures/' + str(i) + '.png', img)
# cv2.imshow(str(train_batch_ys[idx]), img)
cv2.waitKey(100)
cv2.destroyAllWindows()
class AverageMeter(object):
3
Source : lmk2angle.py
with Apache License 2.0
from achao2013
with Apache License 2.0
from achao2013
def isRotationMatrix(R):
''' checks if a matrix is a valid rotation matrix(whether orthogonal or not)
'''
Rt = np.transpose(R)
shouldBeIdentity = np.dot(Rt, R)
I = np.identity(3, dtype = R.dtype)
n = np.linalg.norm(I - shouldBeIdentity)
return n < 1e-6
def matrix2angle(R):
3
Source : camera.py
with Apache License 2.0
from achao2013
with Apache License 2.0
from achao2013
def isRotationMatrix(R):
''' checks if a matrix is a valid rotation matrix(whether orthogonal or not)
'''
Rt = np.transpose(R)
shouldBeIdentity = np.dot(Rt, R)
I = np.identity(3, dtype = R.dtype)
n = np.linalg.norm(I - shouldBeIdentity)
return n < 1e-6
def matrix2angle(R):
3
Source : __init__.py
with Apache License 2.0
from achao2013
with Apache License 2.0
from achao2013
def tensor2im(image_tensor, imtype=np.uint8, cent=1., factor=255./2.):
image_numpy = image_tensor[0].cpu().float().numpy()
image_numpy = (np.transpose(image_numpy, (1, 2, 0)) + cent) * factor
return image_numpy.astype(imtype)
def im2tensor(image, imtype=np.uint8, cent=1., factor=255./2.):
3
Source : __init__.py
with Apache License 2.0
from achao2013
with Apache License 2.0
from achao2013
def tensor2im(image_tensor, imtype=np.uint8, cent=1., factor=255./2.):
# def tensor2im(image_tensor, imtype=np.uint8, cent=1., factor=1.):
image_numpy = image_tensor[0].cpu().float().numpy()
image_numpy = (np.transpose(image_numpy, (1, 2, 0)) + cent) * factor
return image_numpy.astype(imtype)
def im2tensor(image, imtype=np.uint8, cent=1., factor=255./2.):
3
Source : CycleGAN.py
with MIT License
from Adi-iitd
with MIT License
from Adi-iitd
def show_image(image):
image = np.transpose((image + 1) / 2, (1, 2, 0))
plt.imshow(image)
@staticmethod
3
Source : CycleGAN.py
with MIT License
from Adi-iitd
with MIT License
from Adi-iitd
def tensor_to_numpy(tensor):
tensor = (tensor.cpu().clone() + 1) / 2
if len(tensor.shape) == 3: tensor = np.transpose(tensor, (1, 2, 0))
elif len(tensor.shape) == 4: tensor = np.transpose(tensor, (0, 2, 3, 1))
return tensor
@staticmethod
3
Source : train_SE.py
with MIT License
from adigasu
with MIT License
from adigasu
def preprocessData(imArray):
# [w, h, b] --> [b, h, w, ch], ch =1
imgWidth, imgHeight, nbatch = imArray.shape
imArray = np.transpose(imArray, (2,1,0))
imArray = np.reshape(imArray, (nbatch, imgHeight, imgWidth, 1))
imArray = (imArray.astype('float32'))/ 255
return imArray
# Center crop image
def crop_center(img, cX, cY):
3
Source : visualize.py
with MIT License
from aditya30394
with MIT License
from aditya30394
def make_image(img, mean=(0,0,0), std=(1,1,1)):
for i in range(0, 3):
img[i] = img[i] * std[i] + mean[i] # unnormalize
npimg = img.numpy()
return np.transpose(npimg, (1, 2, 0))
def gauss(x,a,b,c):
3
Source : test_numeric.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_transpose(self):
arr = [[1, 2], [3, 4], [5, 6]]
tgt = [[1, 3, 5], [2, 4, 6]]
assert_equal(np.transpose(arr, (1, 0)), tgt)
def test_var(self):
3
Source : test_regression.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_svd_build(self):
# Ticket 627.
a = array([[0., 1.], [1., 1.], [2., 1.], [3., 1.]])
m, n = a.shape
u, s, vh = linalg.svd(a)
b = dot(transpose(u[:, n:]), a)
assert_array_almost_equal(b, np.zeros((2, 2)))
def test_norm_vector_badarg(self):
3
Source : test_frame.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_numpy_transpose(self):
sdf = SparseDataFrame([1, 2, 3], index=[1, 2, 3], columns=['a'])
result = np.transpose(np.transpose(sdf))
tm.assert_sp_frame_equal(result, sdf)
msg = "the 'axes' parameter is not supported"
tm.assert_raises_regex(ValueError, msg, np.transpose, sdf, axes=1)
def test_combine_first(self):
3
Source : test_base.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_numpy_transpose(self):
for obj in self.objs:
if isinstance(obj, Index):
tm.assert_index_equal(np.transpose(obj), obj)
else:
tm.assert_series_equal(np.transpose(obj), obj)
tm.assert_raises_regex(ValueError, self.errmsg,
np.transpose, obj, axes=1)
class TestNoNewAttributesMixin(object):
3
Source : test_mmio.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_random_symmetric_float(self):
sz = (20, 20)
a = np.random.random(sz)
a = a + transpose(a)
self.check(a, (20, 20, 400, 'array', 'real', 'symmetric'))
def test_random_rectangular_float(self):
3
Source : test_mmio.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_random_symmetric_float(self):
sz = (20, 20)
a = np.random.random(sz)
a = a + transpose(a)
a = scipy.sparse.csr_matrix(a)
self.check(a, (20, 20, 210, 'coordinate', 'real', 'symmetric'))
def test_random_rectangular_float(self):
3
Source : test_basic.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def direct_lstsq(a, b, cmplx=0):
at = transpose(a)
if cmplx:
at = conjugate(at)
a1 = dot(at, a)
b1 = dot(at, b)
return solve(a1, b1)
class TestLstsq(object):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_complex_eig(self):
a = [[1,2],[-2,1]]
w,vl,vr = eig(a,left=1,right=1)
assert_array_almost_equal(w, array([1+2j, 1-2j]))
for i in range(2):
assert_array_almost_equal(dot(a,vr[:,i]),w[i]*vr[:,i])
for i in range(2):
assert_array_almost_equal(dot(conjugate(transpose(a)),vl[:,i]),
conjugate(w[i])*vl[:,i])
def test_simple_complex(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_complex(self):
a = [[1,2,3],[1,2,3],[2,5,6+1j]]
w,vl,vr = eig(a,left=1,right=1)
for i in range(3):
assert_array_almost_equal(dot(a,vr[:,i]),w[i]*vr[:,i])
for i in range(3):
assert_array_almost_equal(dot(conjugate(transpose(a)),vl[:,i]),
conjugate(w[i])*vl[:,i])
def test_gh_3054(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_check_finite(self):
a = [[1,2,3],[1,2,3],[2,5,6]]
w,v = eig(a, check_finite=False)
exact_w = [(9+sqrt(93))/2,0,(9-sqrt(93))/2]
v0 = array([1,1,(1+sqrt(93)/3)/2])
v1 = array([3.,0,-1])
v2 = array([1,1,(1-sqrt(93)/3)/2])
v0 = v0 / sqrt(dot(v0,transpose(v0)))
v1 = v1 / sqrt(dot(v1,transpose(v1)))
v2 = v2 / sqrt(dot(v2,transpose(v2)))
assert_array_almost_equal(w,exact_w)
assert_array_almost_equal(v0,v[:,0]*sign(v[0,0]))
assert_array_almost_equal(v1,v[:,1]*sign(v[0,1]))
assert_array_almost_equal(v2,v[:,2]*sign(v[0,2]))
for i in range(3):
assert_array_almost_equal(dot(a,v[:,i]),w[i]*v[:,i])
def test_not_square_error(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple(self):
a = [[1,2,3],[1,20,3],[2,5,6]]
for full_matrices in (True, False):
u,s,vh = svd(a, full_matrices=full_matrices,
lapack_driver=self.lapack_driver)
assert_array_almost_equal(dot(transpose(u),u),identity(3))
assert_array_almost_equal(dot(transpose(vh),vh),identity(3))
sigma = zeros((u.shape[0],vh.shape[0]),s.dtype.char)
for i in range(len(s)):
sigma[i,i] = s[i]
assert_array_almost_equal(dot(dot(u,sigma),vh),a)
def test_simple_singular(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_singular(self):
a = [[1,2,3],[1,2,3],[2,5,6]]
for full_matrices in (True, False):
u,s,vh = svd(a, full_matrices=full_matrices,
lapack_driver=self.lapack_driver)
assert_array_almost_equal(dot(transpose(u),u),identity(3))
assert_array_almost_equal(dot(transpose(vh),vh),identity(3))
sigma = zeros((u.shape[0],vh.shape[0]),s.dtype.char)
for i in range(len(s)):
sigma[i,i] = s[i]
assert_array_almost_equal(dot(dot(u,sigma),vh),a)
def test_simple_underdet(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_underdet(self):
a = [[1,2,3],[4,5,6]]
for full_matrices in (True, False):
u,s,vh = svd(a, full_matrices=full_matrices,
lapack_driver=self.lapack_driver)
assert_array_almost_equal(dot(transpose(u),u),identity(u.shape[0]))
sigma = zeros((u.shape[0],vh.shape[0]),s.dtype.char)
for i in range(len(s)):
sigma[i,i] = s[i]
assert_array_almost_equal(dot(dot(u,sigma),vh),a)
def test_simple_overdet(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_overdet(self):
a = [[1,2],[4,5],[3,4]]
for full_matrices in (True, False):
u,s,vh = svd(a, full_matrices=full_matrices,
lapack_driver=self.lapack_driver)
assert_array_almost_equal(dot(transpose(u),u), identity(u.shape[1]))
assert_array_almost_equal(dot(transpose(vh),vh),identity(2))
sigma = zeros((u.shape[1],vh.shape[0]),s.dtype.char)
for i in range(len(s)):
sigma[i,i] = s[i]
assert_array_almost_equal(dot(dot(u,sigma),vh),a)
def test_random(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_random(self):
n = 20
m = 15
for i in range(3):
for a in [random([n,m]),random([m,n])]:
for full_matrices in (True, False):
u,s,vh = svd(a, full_matrices=full_matrices,
lapack_driver=self.lapack_driver)
assert_array_almost_equal(dot(transpose(u),u),identity(u.shape[1]))
assert_array_almost_equal(dot(vh, transpose(vh)),identity(vh.shape[0]))
sigma = zeros((u.shape[1],vh.shape[0]),s.dtype.char)
for i in range(len(s)):
sigma[i,i] = s[i]
assert_array_almost_equal(dot(dot(u,sigma),vh),a)
def test_simple_complex(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_complex(self):
a = [[1,2,3],[1,2j,3],[2,5,6]]
for full_matrices in (True, False):
u,s,vh = svd(a, full_matrices=full_matrices,
lapack_driver=self.lapack_driver)
assert_array_almost_equal(dot(conj(transpose(u)),u),identity(u.shape[1]))
assert_array_almost_equal(dot(conj(transpose(vh)),vh),identity(vh.shape[0]))
sigma = zeros((u.shape[0],vh.shape[0]),s.dtype.char)
for i in range(len(s)):
sigma[i,i] = s[i]
assert_array_almost_equal(dot(dot(u,sigma),vh),a)
def test_random_complex(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_random_complex(self):
n = 20
m = 15
for i in range(3):
for full_matrices in (True, False):
for a in [random([n,m]),random([m,n])]:
a = a + 1j*random(list(a.shape))
u,s,vh = svd(a, full_matrices=full_matrices,
lapack_driver=self.lapack_driver)
assert_array_almost_equal(dot(conj(transpose(u)),u),identity(u.shape[1]))
# This fails when [m,n]
# assert_array_almost_equal(dot(conj(transpose(vh)),vh),identity(len(vh),dtype=vh.dtype.char))
sigma = zeros((u.shape[1],vh.shape[0]),s.dtype.char)
for i in range(len(s)):
sigma[i,i] = s[i]
assert_array_almost_equal(dot(dot(u,sigma),vh),a)
def test_crash_1580(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_check_finite(self):
a = [[1,2,3],[1,20,3],[2,5,6]]
u,s,vh = svd(a, check_finite=False, lapack_driver=self.lapack_driver)
assert_array_almost_equal(dot(transpose(u),u),identity(3))
assert_array_almost_equal(dot(transpose(vh),vh),identity(3))
sigma = zeros((u.shape[0],vh.shape[0]),s.dtype.char)
for i in range(len(s)):
sigma[i,i] = s[i]
assert_array_almost_equal(dot(dot(u,sigma),vh),a)
def test_gh_5039(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple(self):
a = [[8,2,3],[2,9,3],[5,3,6]]
q,r = qr(a)
assert_array_almost_equal(dot(transpose(q),q),identity(3))
assert_array_almost_equal(dot(q,r),a)
def test_simple_left(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_pivoting(self):
a = np.asarray([[8,2,3],[2,9,3],[5,3,6]])
q,r,p = qr(a, pivoting=True)
d = abs(diag(r))
assert_(all(d[1:] < = d[:-1]))
assert_array_almost_equal(dot(transpose(q),q),identity(3))
assert_array_almost_equal(dot(q,r),a[:,p])
q2,r2 = qr(a[:,p])
assert_array_almost_equal(q,q2)
assert_array_almost_equal(r,r2)
def test_simple_left_pivoting(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_trap(self):
a = [[8,2,3],[2,9,3]]
q,r = qr(a)
assert_array_almost_equal(dot(transpose(q),q),identity(2))
assert_array_almost_equal(dot(q,r),a)
def test_simple_trap_pivoting(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_trap_pivoting(self):
a = np.asarray([[8,2,3],[2,9,3]])
q,r,p = qr(a, pivoting=True)
d = abs(diag(r))
assert_(all(d[1:] < = d[:-1]))
assert_array_almost_equal(dot(transpose(q),q),identity(2))
assert_array_almost_equal(dot(q,r),a[:,p])
q2,r2 = qr(a[:,p])
assert_array_almost_equal(q,q2)
assert_array_almost_equal(r,r2)
def test_simple_tall(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_tall(self):
# full version
a = [[8,2],[2,9],[5,3]]
q,r = qr(a)
assert_array_almost_equal(dot(transpose(q),q),identity(3))
assert_array_almost_equal(dot(q,r),a)
def test_simple_tall_pivoting(self):
3
Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_simple_tall_pivoting(self):
# full version pivoting
a = np.asarray([[8,2],[2,9],[5,3]])
q,r,p = qr(a, pivoting=True)
d = abs(diag(r))
assert_(all(d[1:] < = d[:-1]))
assert_array_almost_equal(dot(transpose(q),q),identity(3))
assert_array_almost_equal(dot(q,r),a[:,p])
q2,r2 = qr(a[:,p])
assert_array_almost_equal(q,q2)
assert_array_almost_equal(r,r2)
def test_simple_tall_e(self):
See More Examples