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

How can you move data from column b and append to the end of column a using Python?
NLTK classification probability estimate with n-grams
I am trying to do an if statement with the input to be 21 and the result be Time printed out
Why won't my code work for all palindromes?
Tkinter progess bar using Frame
How to save a Seaborn plot into a file
Parse XML time series data to dat files
Google App Engine DB Query Memory Usage
Taking two lists and printing specific characters based on their postition
How to call a C++ function which returns a vector of doubles from Python?
Force datetime with hour and minutes to null pandas
Difference between _sql_constraints and _constraints on OpenERP/Odoo?
Is there a Python JSON encoder which JUST works?
Parse large split XML file(s) with Python
Tried everything but still cannot serve static files of Django project via nginx+gunicorn
Bin values based on ranges with pandas

Categories

HOME
visual-studio-2015
sql-server
cakephp-3.x
meshlab
vhdl
drupal-7
paramiko
visual-studio-2013
jasmine
hana
windows-store-apps
chaiscript
phonegap-cli
pygame
internet-explorer-11
xcode8.3
gimp
constructor
window
tee
mongodb-query
typeahead
uisplitviewcontroller
netezza
opera-mini
uicollectionview
apache-karaf
boolean-expression
styles
jive
sonarqube-msbuild-runner
scalaz7
qsub
switching
guile
vcard
reactiveui
positioning
superagent
websauna
red-black-tree
vegan
rowcount
modelandview
von-neumann
openpgp
shibboleth
rider
mmdrawercontroller
bigcartel
vmd
installshield-2012
flex4.5
ical-dotnet
google-account
html-agility-pack
ivona
lumen-5.3
tableau-server
windows-firewall
uiviewpropertyanimator
jags
spring-data-hadoop
modelattribute
qos
spyne
keycode
build-process
ebtables
vst
update-site
portfolio
file-diffs
rad
futuretask
visual-studio-code
wif
twython
django-1.6
viewflipper
utf-32
gmaps4rails
jquery-autocomplete
errorprovider
ogr2ogr
docopt
log4cplus
csplit
funkload
visualstatemanager
initialization-vector
json-patch
arangodb-php
document-database
vertical-rhythm
goinstant
trimming
nuspec
pep8
android-contextmenu
linkedhashset
pstree
getstring
selectmanycheckbox
nsindexpath
throttling
ou
smooth
server-error
libavformat
carbide
openvg
msf

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