Navigation

    Möbius Community
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    Need help? Ask here!
    Best Practices
    Quick Code Snippets
    Inspiration
    1. Home
    2. tomdavies
    T
    • Continue chat with tomdavies
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    tomdavies

    @tomdavies

    0
    Reputation
    3
    Posts
    2363
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    tomdavies Follow
    TA School UoB Maple TA Interns 2016

    Posts made by tomdavies

    • Grading Code: Check if the rows of a matrix form a basis of a 2 dimensional vector space
      #
      # Checks if input is a basis of some 2d vector space
      #
      # Takes:    mat        (matrix with rows as basis vectors)
      #           ans1, ans2 (some correct basis vectors)
      #
      mat  := Matrix([[1,1],[0,3]]):
      ans1 := Matrix([1,1]):
      ans2 := Matrix([0,3]):
      isMultiple := proc(vec1, vec2):
          matCheck := LinearAlgebra:-Transpose(Matrix([[vec1], [vec2]])):
          ans := 0:
          if evalb(LinearAlgebra:-Determinant(matCheck) = 0) then:
              ans := 1:
          end if:
          ans:
      end proc:
      result := "unknown":
      dim := LinearAlgebra:-Dimension(mat):
      if (evalb(dim[1] <> 2) or evalb(dim[2] <> 2)) then:
          result := 0:
      else:
          v1 := mat[1, 1..2]:
          v2 := mat[2, 1..2]:
          if evalb(isMultiple(v1,v2) = 0) then:
              if evalb(isMultiple(v1, ans1) = 1) then:
                  if evalb(isMultiple(v2, ans2) = 1) then:
                      result := "1":
                  else:
                      result := "0":
                  end if:
              elif evalb(isMultiple(v2, ans1) = 1) then:
                  if evalb(isMultiple(v1, ans2) = 1) then:
                      result := "1":
                  else:
                      result := "0":
                  end if:
              else
                  result := "0":
              end if:
          else:
              result := "0":
          end if:
      end if:
      print(result);
      posted in Quick Code Snippets
      T
      tomdavies

    About Us

    This forum aims to connect DigitalEd's users. For official Möbius support, please see https://www.digitaled.com/support/.

    Contact Info

    630 Weber Street North
    Suite 100
    Waterloo, ON Canada
    N2V 2N2
    .
    1.888.355.4511
    info@digitaled.com

    Community

    Quick Links

    Categories Recent Tags Popular Users Search

    Möbius Community Forum

    © DigitalEd, a division of Digital Education Ltd. 2018.   •  Terms of Use | Privacy | Trademarks

    Powered by NodeBB Forums | Contributors