Difficulty in understanding float function in pseudocode - raptor

I am just a beginner. I am learning programming right now and I am having problem in understanding few functions like float and cieling, I would like to know when and why do we use them?

When you talk about float if you talk about the variable float, you will use it when you have a number that has decimals,you can learn more about it just searching in Google

Related

How to multiply matrices containing floating points in FPGA?

I would like to ask a question about matrix multiplication in HDL. For 6 months I have been learning about FPGAs and ASIC design, but still do not have the enough experience for programming FPGAs using Verilog/VHDL. I had a quick search and found that Verily is suitable for me. Anyway, you just suppose me as a beginner and till now I only followed simple tutorials made of using Xilinx Spartan 3E-XCS1600E MicroBlaze Starter Kit, because I have it, too.
The most challenging part for me was to create matrices in Verilog. If I am able to create matrices and fill them with integers first, then I can move on the next step matrices with floating numbers. In advance, I also want to take inverse of these matrix and seems hard to me extremely.
My question is, what should I do in order to multiply matrices? Is there any tricky or easier way to do that like in C language? (I know Verilog is a HDL and we cannot think on that way). Also how can I convert my floating numbers to fixed or integer type? Then I think I can solve my problem in this way. I looked trough other questions but did not understand well. Thanks for your response and help.
Bonus Question: If I try these operations on MATLAB or Simulink, could it be easier to convert it to HDL using HDL Coder? If it is, could you guide me to do that?
Regards,
Leonardo
You can create matrices with RAM in hardware design. Actually, everything can be described as RAM:)
Of course only integer can be supported in Verilog, but we do have some method that can create and compute float numbers.
Define a float syntax. Suppose that we have reg var[7:0], we can assume var[7:4] is the integer part and var[3:0] is the decimal part. Like 8'b0101_1001 equals 5.9 in DEC. You must limit the range of var[3:0] to 0~9!
IEEE 754. http://grouper.ieee.org/groups/754/ This standard has been widely used in many areas, but I think it will be a little difficult for you.
Deal with a matrices is nothing special, just follow what you have learned in math class.
I'm not good at English. Hope you can understand.

Static/Quasi-Static solver in Dymola/Modelica?

I know it might be dumb to ask such a question because Dymola is short for Dynamic Model laboratory, and I should use modelica/dymola to solve dynamic problems.
However, I still wonder if it is possible to get some kind of quasi-static result from it by using the same model?
For example:
For a simple mass spring damper system, we have
F = mx_dotdot+cx_dot+kx
Of course, modelica is good at handling this kind of problem. What my question is, is there a way to tell the solver that the dynamic components(states) should all be zero without modifying the original model? Then at each time step, I could get a static solution.
F = kx
Thanks ahead for any answers!

J2ME power(double, double) math function implementation

I want to implement math function power to double, can you advice algorithm for this?
I've reviewed sources of Java ME Open Source Software - Math but I want to implement it from the scratch.
Thank you!
I don't know J2ME well enough to know, but do you have Math.log() and Math.exp() ?
Then you can simply use this relation:
x^y = exp(y * log(x))
If you don't have the aforementioned two functions, then you should start by implementing those. As far as I know, the above relation is the only reasonable way to compute x^y.
Update: I see the paper linked in kusman's answer shows an alternative way to do pow using the idea of a fractional exponent. Quite cool! But the paper also shows the "normal" way to do things via multiplication of the log, and shows you how to implement Taylor series for exp() and log().

Knowledge required to build your own integer class?

Upon reaching a brick wall with the .Net framework's lack of a BigInteger class (yet), I've decided I'd like to develop my own as an exercise (I realize open source alternatives exist). What hoops do I need to jump through to be able to develop this? Is there any particuliar knowledge pieces that I probably wouldn't have?
edit: side question. Which data type would you use to represent the numbers inside of your new big integer class?
Arbitrary precision arithmetic?
Edit: To represent your numbers you will probably want a resizeable array of integers.
I would brush up on your basic math skills. When I wrote a Big Int class I had to remember how to add, multiply and divide by hand like in Elementary school.
Next if you are going to create a new class I would try to follow the standards that have been set up for the Framework. So it looks like any other .Net class.
I would follow TDD so you know your class works the way it is designed.
You need to have a very good understanding of number systems. You could choose to represent the bignum in base 10, base 2 or any base x. This choice would affect your class performance a lot. You also have to choose the algorithms you want to implement. In general, great libraries like GMP for example, choose the algorithm based on the size of the operands. There are a lot of topics you have to be aware of, but in the end you should be convinced that you can't produce something really interesting. As a learning topic it is very valuable, but as producing something useful consider NOT reinventing the wheel!
If you want to dive really deep into the math of it, you need to read Donald Knuth.
.Net 3.5 has a BigInteger class, but it's scoped internal to the CLR. You can see the code using Reflector. Open System.Core.dll and look in the System.Numeric namespace. BigInteger is the only class in that namespace.
If you want to see the code for the F# BigInteger class, look in the [F# install folder]\source\fsharp\FSharp.Core\math\z.fs file.
Maybe studying an already implemented BigInteger class might help?
If you use elementary algorithms, your BigInts will be unusable for very large integers, for example like Mersenne Primes.
If this is ok for you, use a simple 32 bit int as the basic data type. You need to handle 64 results in this case. If you don't care about speed at all, use some radix-10 number as base, lets say 10000, which will be very easy to implement.
This is mainly because the multiplication in a naive implementation has O(n^2) runtime. Advanced algorithms, based on fourier transforms, have O(n(log(n)) runtime.
This requires some mathematical skills and knowledge.

Algebraic logic

Both Wolfram Alpha and Bing are now providing the ability to solve complex, algebraic logic problems (ie "solve for x, given this equation"), and not just evaluate simple arithmetic expressions (eg "what's 5+5?"). How is this done?
I can read most types of code that might get thrown at me, so it doesn't really make a difference what you use to explain and represent the algorithm. I find that bash makes a really good pseudo-code, not to mention its actually functional, so that'd be ideal. Also, I'm fairly familiar with its in's and out's. Sorry to go ranting on a tangent, but it really irritates me to see people spend effort on crunching out "pseudocode" when they could be getting something 100% functional for just slightly more effort. Anyways, thanks so much for advance.
There are 2 main methods to solve:
Numeric methods. Numerical methods mean, basically, that the solver tries to change the value of x until the equation is satisfied. More info on numerical methods.
Symbolic math. The solver manipulates the equation as a string of symbols, by a number of formal rules. It's not that different from algebra we learn in school, the solver just knows a lot of different rules. More info on computer algebra.
Wolfram|Alpha (W|A) is based on the Mathematica kernel, combined with a natural language parser (which is also built primarily with Mathematica). They have a whole heap of curated data and associated formula that can be used once the question has been interpreted.
There's a blog post describing some of this which came out at the same time as W|A.
Finally, Bing simply uses the (non-free) API to answer questions via W|A.

Resources