- >>> import numpy
-
>>> def backsub(X, y):
-
l = shape(X)
-
n = l[1]
-
X = mat("1. 2. 3.; 0. 3. 2.; 0. 0. 1.")
-
y = mat(" 2.; 4.; 5.")
-
b = zeros((n,1))
-
b[n-1, 0] = y[n-1, 0]/X[n-1, n-1]
-
for j in range(n-1,0,-1):
-
b[j-1,0] = (y[j-1,0] - dot(X[j-1, range(j,n)], b[range(j,n),0]))/X[j-1, j-1]
-
return b
-
print (b)
2 4235 dwblas 626
Recognized Expert Contributor
You should be able to debug this yourself by adding a few simple print statements to see what is executing and what is not. No offense intended, but it is a waste of everyones time to post this, and you don't want people ignoring your questions because they were like this one in the past. Post back if you can't find the error, posting the complete error message and code that shows that you have attempted to find the problem yourself.
dwblas 626
Recognized Expert Contributor
And if you keyed this into the python interpreter on the console, use a text editor, https://wiki.python.org/moin/PythonEditors or IDLE (comes with python) so you can save the file, change it, run it again, etc.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Martin Drautzburg |
last post by:
Withing a module I can assign a value to a global var by assigning to
it in the outermost scope. Fine.
But how can I do this if the attribute name itself is kept in a
variable. Once the module is loaded I can access the module's
namespace no problem, but inside the module the dictionary is not yet
present right ?
IOW how can I write something like
|
by: jolly |
last post by:
hey guys,
When i try to run my code I get an error. NameError name 'main is not
defined'
if __name__ == "__main__":
main()
filename = "addbook.dat"
|
by: willkab6 |
last post by:
I am very new to both programming and Pyhton and while trying to do
some practice using A byte of python an Error pops up on the IDLE
shell. I am using windows XP. PLease see below.
while running:
guess = int(raw_input('Enter an integer : '))
if guess == number:
print 'Congratulations, you guessed it.'
running = False # this causes the while loop to stop
elif guess < number:
|
by: tshravan |
last post by:
Hello All,
I am newbie to python.
I was trying to use a=zeros(5) in python shell, but it is throwing the following exception in the shell
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'zeros' is not defined
|
by: manojnkumar |
last post by:
#This is to add, sub, mul and div using functions
def menu():
print ""
print "Welcome to the calculator"
print "===== These are some of the options ====="
print "1--> for Addition"
print "2--> for Subtraction"
print "3--> for muliplication"
| |
by: Mathieu Prevot |
last post by:
Hi
I import subprocess and use Popen, but PIPE is not defined. I used
2.5.1, 2.5.2, Python 2.6a3+ (trunk:63576, May 24 2008, 12:13:40), it's
always the same. What am I missing ?
Thanks
Mathieu
|
by: cirfu |
last post by:
im doing the python challenge and well, i solved this problem with
ruby :)
phrase = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq
ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr
gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc
spj."
puts phrase .tr('A-XY-Za-xy-z','C-ZA-Bc-za-b')
the answer says to use maketrans but i cant get it to work:
|
by: Harry |
last post by:
Hi there. I am trying to download a file(sn.last) from a public FTP
server with the following code:
from ftplib import FTP
ftp=FTP('tgftp.nws.noaa.gov')
ftp.login()
ftp.cwd('SL.us008001/DF.of/DC.radar/DS.81dpr/SI.kbuf')
ftp.retrbinar('RETR sn.last', open(mydpa,'wb').write)
ftp.quit()
|
by: harijay |
last post by:
Hi I am new to writing module and object oriented python code. I am
trying to understand namespaces and classes in python.
I have the following test case given in three files runner , master
and child. I am getting an error within child where in one line it
understands variable master.name and in the next line it gives a
NameError as given here
" print "Reset name now from %s to %s , oldname %s is saved in
mastertrash" %...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |