Merge pull request #270 from D-T-666/master

Minor cleanup, updated README
This commit is contained in:
Luke Weiler
2020-10-19 19:03:44 -04:00
committed by GitHub
7 changed files with 124 additions and 99 deletions

View File

@@ -1,16 +1,21 @@
from .euclidianNormFunc import euclidianNormFunc
import math
from .__init__ import *
def angleBtwVectorsFunc(v1: list, v2: list):
sum = 0
def angleBtwVectorsFunc(maxEltAmt=20):
s = 0
v1 = [random.uniform(0, 1000) for i in range(random.randint(2, maxEltAmt))]
v2 = [random.uniform(0, 1000) for i in v1]
for i in v1:
for j in v2:
sum += i * j
s += i * j
mags = euclidianNormFunc(v1) * euclidianNormFunc(v2)
mags = math.sqrt(sum([i**2 for i in v1])) * math.sqrt(sum([i**2 for i in v2]))
problem = f"angle between the vectors {v1} and {v2} is:"
solution = math.acos(sum / mags)
solution = ''
try:
solution = str(math.acos(s / mags))
except MathDomainError:
print('angleBtwVectorsFunc has some issues with math module, line 16')
solution = 'NaN'
# would return the answer in radians
return problem, solution

View File

@@ -1,7 +1,8 @@
from .__init__ import *
def euclidianNormFunc(v1: list):
problem = f"Euclidian norm or L2 norm of the vector{v1} is:"
solution = sqrt(sum([i**2 for i in v1]))
def euclidianNormFunc(maxEltAmt=20):
vec = [random.uniform(0, 1000) for i in range(random.randint(2, maxEltAmt))]
problem = f"Euclidian norm or L2 norm of the vector{vec} is:"
solution = math.sqrt(sum([i**2 for i in vec]))
return problem, solution

View File

@@ -1,10 +1,10 @@
from .__init__ import *
def matrixMultiplicationFunc(maxVal=100):
m = random.randint(2, 10)
n = random.randint(2, 10)
k = random.randint(2, 10)
def matrixMultiplicationFunc(maxVal=100, max_dim=10):
m = random.randint(2, max_dim)
n = random.randint(2, max_dim)
k = random.randint(2, max_dim)
# generate matrices a and b
a = []

View File

@@ -23,8 +23,8 @@ class Generator:
self.id
) + " " + self.title + " " + self.generalProb + " " + self.generalSol
def __call__(self, **kwargs):
return self.func(**kwargs)
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)
# || Non-generator Functions