python


Extend a matrix by interpolating zeros


I am trying to implement a python code to extend a matrix in such a way as given below:
Given Matrix:
1 2
3 4
Now I want to convert it to the following:
1 0 0 2 0 0
0 0 0 0 0 0
0 0 0 0 0 0
3 0 0 4 0 0
0 0 0 0 0 0
0 0 0 0 0 0
I am trying the same for a matrix of the dimensions 60x80. I tried out numpy.insert(). But for larger matrix I am not able to apply the same thing(as it becomes too much hardcoding). So need some suggestions to do such interpolation.
You can use the step part of the slice to achieve this, if you preallocate yourself a result
repeat = 3
result = np.zeros((arr.shape[0]*repeat, arr.shape[1]*repeat))
result[::repeat,::repeat] = arr

Related Links

Linear interpolation within groups
Is it possible to turn a widget [Kivy]
Want to create a thumbnail(25,25) of an Image of size (181,256) using python
python code to get values from json data
Math domain error when trying to graph equation of circle with polar coordinates in python
Converting base 6 to decimal and vice versa in Python? [closed]
Labelling Segments in Turtle
How to test that functools.partial produces the expected function object
Django CreateView Auto Login
Dictionary comprehension to build list of lists: referencing the current value for a key during comprehension
Python:Errno 22 Invalid argument
Class initialisation issue python
Python def replace
How get back a proper json that was stored with fileInfo without the escape sequences?
django-admin.py not working properly in powershell
Best way to dynamically show all keys for arrays in Python

Categories

HOME
security
redis
npm
google-tag-manager
angular2-routing
laravel-5.3
translation
deep-linking
h2
schemacrawler
eclipse-cdt
data-synchronization
local
simple-injector
bootstrap-popover
mule-studio
mousewheel
android-fragmentactivity
multiplayer
binutils
npm-install
http-method
croppic
sumo
compare-and-swap
pep8-assembly
stocks
getline
pox
xamarin.uitest
axis-labels
lexical-analysis
tripwire
g1gc
intersystems-ensemble
homekit
fastq
azure-availability-set
production-environment
livefyre
ticker
tofixed
mercury
autoresize
onresume
pdfkit
barcode-printing
svn-merge
multifile-uploader
gradle-eclipse
mongoskin
emokit
interactive-brokers
asp.net-mvc-2
multinomial
geodjango
enyo
uialertview
ipojo
rx-groovy
hiera
sqoop2
ctrlp
line-numbers
gyroscope-framework
docopt
dalekjs
author
yahoo-boss-api
neoload
crystal-reports-10
svcutil.exe
bsod
nsmatrix
layered
leptonica
database-permissions
prng
htmltextwriter
marmalade-edk
lync-server-2010
javascriptserializer
viewdidload
wchar
mysql-error-1045
shared-objects
webkit-transform
cookieless
rubycas
phpcrawl

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App