def __add__(self, vectorX): ''' Method to add a vector (of the same size) to the currect vector. The resulting vector will be the result of element-wise addition. @param vectorX: vector to be added. @type vectorX: copads.matrix.Vector object @return: resulting copads.matrix.Vector object ''' if len(self.values) != len(vectorX.values): raise VectorError('Vectors have different sizes') try: values = [ self.values[i] + vectorX.values[i] for i in range(len(self.values)) ] return Vector(values) except: raise VectorError('Failure in Vector.__add__()')
def log10(self): ''' Method to perform element-wise log10 on the vector. @return: result vector as a list. ''' try: values = [math.log10(x) for x in self.values] except: raise VectorError('Failure in Vector.log10()') self.values = values return self.values
def sqrt(self): ''' Method to perform element-wise square root on the vector. @return: result vector as a list. ''' try: values = [math.sqrt(x) for x in self.values] except: raise VectorError('Failure in Vector.sqrt()') self.values = values return self.values
def acos(self): ''' Method to perform element-wise arc cosine in radians on the vector. @return: result vector as a list. ''' try: values = [math.acos(x) for x in self.values] except: raise VectorError('Failure in Vector.a()') self.values = values return self.values
def tan(self): ''' Method to perform element-wise tangent in randians on the vector. @return: result vector as a list. ''' try: values = [math.tan(x) for x in self.values] except: raise VectorError('Failure in Vector.tan()') self.values = values return self.values
def exp(self): ''' Method to perform element-wise exponential (e to the power of the value) on the vector. @return: result vector as a list. ''' try: values = [math.exp(x) for x in self.values] except: raise VectorError('Failure in Vector.exp()') self.values = values return self.values
def atanh(self): ''' Method to perform element-wise inverse hyperbolic tangent in radians on the vector. @return: result vector as a list. ''' try: values = [math.atanh(x) for x in self.values] except: raise VectorError('Failure in Vector.atanh()') self.values = values return self.values
def log(self, base=math.e): ''' Method to perform element-wise log on the vector. @param base: base value of the logarithmic function. Default = e. @type base: float @return: result vector as a list. ''' base = float(base) try: values = [math.log(x, base) for x in self.values] except: raise VectorError('Failure in Vector.log()') self.values = values return self.values
def root(self, n): ''' Method to perform element-wise n-th root on the vector. @param n: value of the root. @type n: float @return: result vector as a list. ''' n = float(n) try: values = [float(x)**(1.0 / float(n)) for x in self.values] except: raise VectorError('Failure in Vector.root()') self.values = values return self.values
def pow(self, n): ''' Method to perform element-wise power (value to the power of n) on the vector. @param n: exponent to be raised. @type n: float @return: result vector as a list. ''' n = float(n) try: values = [float(x)**n for x in self.values] except: raise VectorError('Failure in Vector.pow()') self.values = values return self.values