Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class for Vector
#3
(Oct-06-2019, 02:44 PM)buran Wrote: Please, don't post images of code. Copy/paste in python tags. See BBcode help for more info.
Sorry, there is:
class MyVector:
  def __init__(self, a):
    self.a = a

  def get_vector(self):
    return(self.a)

  def __mul__(self, other):
    dot_product = 0
    for x in range(len(self.a)):
      dot_product += self.a[x]*other.a[x]
      return dot_product
Reply


Messages In This Thread
Class for Vector - by no_named_nobody - Oct-06-2019, 02:16 PM
RE: Class for Vector - by buran - Oct-06-2019, 02:44 PM
RE: Class for Vector - by no_named_nobody - Oct-06-2019, 02:50 PM
RE: Class for Vector - by buran - Oct-06-2019, 02:57 PM
RE: Class for Vector - by no_named_nobody - Oct-06-2019, 03:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  vector field plots Larssauerkraut 0 1,545 Oct-15-2019, 11:15 AM
Last Post: Larssauerkraut
  Divide a vector Langosmon 1 2,705 May-13-2018, 09:09 AM
Last Post: ThiefOfTime
  Classification by support vector method qwerty 1 2,957 Apr-16-2017, 07:16 PM
Last Post: sparkz_alot
  vector sum of tuples roadrage 7 7,720 Nov-28-2016, 09:54 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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