algebra

How to fix 'Float' object has no attribute 'exp'?

筅森魡賤 提交于 2019-12-02 07:28:14
I have the following Gaussian equation in Python: numpy.exp((-(x-m)**2)/(2*sigma)) Provided that x is an matrix. However, the equation won't run, and I get the following error: AttributeError: 'Float' object has no attribute 'exp' How can I solve this issue? EDIT-1 Making the following edit: map(float(),np.exp((-(x-m)**2)/(2*sigma))) Raised the error: TypeError: 'float' object is not callable EDIT-2 This is a sample of the value x : [[-0.20646505 0.07763347 -0.16161097 0.370439 ] [-0.91295327 -0.73768934 -0.78909055 0.06156045] [-0.37242104 0.51828245 -1.16138222 -0.02489585] [-1.07890926 -0

Find coordinates to draw arrow head (isoscele triangle) at the end of a line

十年热恋 提交于 2019-12-02 02:18:54
问题 I am trying to create a function that will return the 3 points coordinates of arrow head (isoscele triangle) that I want to draw at the end of a line. The challenge is in the orientation (angle) of the line that can vary between 0 and 360 degree in the quadrant. I have the following values: //start coordinates of the line var x0 = 100; var y0 = 100; //end coordinates of the line var x1 = 200; var y1 = 200; //height of the triangle var h = 10; //width of the base of the triangle var w = 30 ;

Simplification Algorithm for Reverse Polish Notation

≡放荡痞女 提交于 2019-12-01 12:27:19
A couple of days ago I played around with Befunge which is an esoteric programming language. Befunge uses a LIFO stack to store data. When you write programs the digits from 0 to 9 are actually Befunge-instructions which push the corresponding values onto the stack. So for exmaple this would push a 7 to stack: 34+ In order to push a number greater than 9, calculations must be done with numbers less than or equal to 9. This would yield 123. 99*76*+ While solving Euler Problem 1 with Befunge I had to push the fairly large number 999 to the stack. Here I began to wonder how I could accomplish

Simplification Algorithm for Reverse Polish Notation

荒凉一梦 提交于 2019-12-01 11:46:31
问题 A couple of days ago I played around with Befunge which is an esoteric programming language. Befunge uses a LIFO stack to store data. When you write programs the digits from 0 to 9 are actually Befunge-instructions which push the corresponding values onto the stack. So for exmaple this would push a 7 to stack: 34+ In order to push a number greater than 9, calculations must be done with numbers less than or equal to 9. This would yield 123. 99*76*+ While solving Euler Problem 1 with Befunge I

Find the sids of the suppliers who supply every part

徘徊边缘 提交于 2019-12-01 10:51:57
3 tables: Suppliers(sid, sname, address), Parts(pid, pname, colour), Catalog(sid, pid, cost) The answer to find all the suppliers who supply every part is: SELECT C.sid FROM Catalog C WHERE NOT EXISTS ( SELECT P.pid FROM Parts P WHERE NOT EXISTS ( SELECT C1.sid FROM Catalog C1 WHERE C1.sid = C.sid AND C1.pid = P.pid ) ) Could someone explain this answer to me? I'm just a bit lost! I've heard it explained as 'Find suppliers such that there does not exist a part that they do not sell', but I'm struggling to see how SELECT C1.sid FROM Catalog C1 WHERE C1.sid = C.sid AND C1.pid = P.pid )

Find the sids of the suppliers who supply every part

一个人想着一个人 提交于 2019-12-01 07:32:45
问题 3 tables: Suppliers(sid, sname, address), Parts(pid, pname, colour), Catalog(sid, pid, cost) The answer to find all the suppliers who supply every part is: SELECT C.sid FROM Catalog C WHERE NOT EXISTS ( SELECT P.pid FROM Parts P WHERE NOT EXISTS ( SELECT C1.sid FROM Catalog C1 WHERE C1.sid = C.sid AND C1.pid = P.pid ) ) Could someone explain this answer to me? I'm just a bit lost! I've heard it explained as 'Find suppliers such that there does not exist a part that they do not sell', but I'm

Performing algebra with newtypes based on integers Haskell

微笑、不失礼 提交于 2019-12-01 06:31:34
I'm having some trouble with performing simple addition, subtraction -- any kind of algebra really with Haskells newtype. My definition is (show included so I can print them to console): newtype Money = Money Integer deriving Show What I'm trying to do is basically: Money 15 + Money 5 = Money 20 Money 15 - Money 5 = Money 10 Money 15 / Money 5 = Money 3 And so on, but I'm getting m = Money 15 n = Money 5 Main>> m-n ERROR - Cannot infer instance *** Instance : Num Money *** Expression : m - n I can't find a clear and consise explanation as to how the inheritance here works. Any and all help

Is there C++ class that implements operations with permutations?

故事扮演 提交于 2019-12-01 05:49:19
Is there C++ template class that implements operations with permutations and permutation group? Such class has to implement finding product and inverse, multiplication, etc. I don't know of one, but it should be easy enough to implement. Internally you could represent the permutation as a vector e.g. (1 3 4 2 7 5 6) being a perm of 1-7 sending 1->1, 2->3, 3->4, 4->2 etc. or as a set of cycles e.g. (1) (2 3 4) (5 7 6), and implement the operations in terms of these. Presumably the template argument would be the size of the permutation group. 来源: https://stackoverflow.com/questions/1205744/is

Performing algebra with newtypes based on integers Haskell

…衆ロ難τιáo~ 提交于 2019-12-01 04:53:18
问题 I'm having some trouble with performing simple addition, subtraction -- any kind of algebra really with Haskells newtype. My definition is (show included so I can print them to console): newtype Money = Money Integer deriving Show What I'm trying to do is basically: Money 15 + Money 5 = Money 20 Money 15 - Money 5 = Money 10 Money 15 / Money 5 = Money 3 And so on, but I'm getting m = Money 15 n = Money 5 Main>> m-n ERROR - Cannot infer instance *** Instance : Num Money *** Expression : m - n

Finite Field Linear Algebra Library for Haskell

ぃ、小莉子 提交于 2019-12-01 03:45:41
I'm searching for a finite field linear algebra library for Haskell. Something like FFLAS-FFPACK for Haskell would be great :-). Of course, I checked hmatrix , there seems to be some support for arbitrary matrix element types but I couldn't find any finite field library which works with hmatrix. And surely I'd appreciate a performant solution :-) In particular I want to be able to multiply 𝔽 p n×1 and 𝔽 p 1×m matrices (vectors) to 𝔽 p n×m matrices. Your best bet would be a binding to FFLAS/FFPACK, that represents the data in native Haskell types. However, I can't see that we have such a