Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matrix Calculation Problem
#5
(Nov-04-2019, 02:55 PM)arshad Wrote: Why j in range(0) is not excuted because it value present in array A. i.e A[1][0]. why the code doesnot pick this value?

range(0) returns a 0. That means that it will NOT iterate (or it will iterate 0 amount of times) and it goes directly to the next iteration on the upper loop where i=2.


This check outputs what you were asking for:
for i in range(n):
    if i <= 1:
        value=1
    else:
        value=i-1
    for j in range(value):
        B[i] += sum + A[i][j]
Output:
[0. 1. 2. 5. 9.]
Reply


Messages In This Thread
Matrix Calculation Problem - by arshad - Nov-04-2019, 09:07 AM
RE: Matrix Calculation Problem - by Gribouillis - Nov-04-2019, 09:20 AM
RE: Matrix Calculation Problem - by baquerik - Nov-04-2019, 09:45 AM
RE: Matrix Calculation Problem - by arshad - Nov-04-2019, 02:55 PM
RE: Matrix Calculation Problem - by baquerik - Nov-04-2019, 03:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Check if two matrix are equal and of not add the matrix to the list quest 3 842 Jul-10-2023, 02:41 AM
Last Post: deanhystad
  Stock Return calculation problem LFin 10 2,131 Sep-26-2022, 04:28 PM
Last Post: deanhystad
  How to multiply a matrix with herself, until the zero matrix results peanutbutterandjelly 3 3,391 May-03-2021, 06:30 AM
Last Post: Gribouillis
  Dataframe mean calculation problem: do we have to loop? sparkt 1 2,186 Aug-28-2020, 02:41 PM
Last Post: sparkt
  Problem in matrix leemao 1 2,168 Jun-27-2020, 12:48 PM
Last Post: Yoriz
  Problem with simple 3D Vektor calculation Pythocodras 0 1,717 Dec-11-2019, 07:18 PM
Last Post: Pythocodras
  Correlation Matrix Problem Pmllz 0 2,027 Feb-02-2019, 10:19 PM
Last Post: Pmllz
  matrix from matrix python numpy array shei7141 1 3,724 Jan-16-2017, 06:10 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020