Jump to content

Sensei

Senior Members
  • Posts

    7713
  • Joined

  • Last visited

  • Days Won

    26

Posts posted by Sensei

  1. I must admit this laptop is very slow at the moment :(

     

    You must start from disallowing this machine connection to Internet.

    Because they're probably still monitoring what you're doing (observing screen-shots taken every second or few seconds, recording keys that you press, listening microphone if you have it, observing room by net camera etc. if you have them built-in, like in top end modern models, you can't even disconnect them).

  2. Did you read carefully that link?

     

    "distilled water is purified and does not contain any impurities, it is unable to conduct electricity. Water molecules on their own have no charge and as a result they cannot swap electrons. Without the swapping of electrons, electricity is unable to travel through distilled water."

     

    One note. It's very simplified version. It's true for low voltages.

    But when voltage is measured in kilo volts or mega volts, exceeding voltage breakdown, even good insulator will start conducting electricity.

  3. [math]E=m_0*c^2*\gamma[/math]

    m0 is rest mass.

     

    [math]m=m_0*\gamma[/math]

    m is relativistic mass.

     

    So when somebody writes:

    [math]E=m*c^2[/math]

    It can also mean the same as the first equation, depending on interpretation of m.

     

    where gamma is:

    [math]\gamma=\frac{1}{\sqrt{1-\frac{v^2}{c^2}}}[/math]

     

    When v=0, [math]\gamma=1[/math] (the same frame of reference as we are)

    The first equation simplifies to:

    [math]E=m_0*c^2[/math]

  4. Maybe I should explain a bit to UK/USA members what is happening (although I doubt you can help without even being able to replicate issue):

    If we have textView control, with inputType=numeric or inputType=numericDecimal etc,

    there is showed special smaller keyboard with just digits,

    and dot keys,

    so we can enter f.e. 3.141265,

    but half of world is using comma as floating point separator, not dot.

     

    When using

    Double Double.parseDouble( String string );

    dot is treated as separator (even if locale is using comma).

    (there is exception while trying to parse string with comma, or it's cut in half)

     

    When using

    String.format( "%f", double );

    where is used locale,

    to print double.

     

    So, if we print double to text, with comma as separator,

    and then try to parse it, with dot as separator,

    it will obviously screw up float/double.

     

    If we try to use

     

     

    String string = textView.getText().toString();
    try
    {
       NumberFormat format = NumberFormat.getInstance();
       Number number = format.parse( string );
       value = number.doubleValue();
    }
    catch ( NumberFormatException e ) {
    }
    catch ( ParseException e ) {
    }
    parsing and printing will be fine, using comma (locale),

    but (virtual) keyboard on smartphone (at least mine) is showing digits keys and dot key, and not comma key,

    so not being able to enter correct separator character,

    and not being able to enter fraction..

  5. Lol. If you would win lottery (if you would play at all), you could buy whole island and build new CERN on it.. :)

    I would certainly do it this way..

    Island on which you need to have PhD/significant scientific achievements to even land on it..

     

    That would be Wilson of cloud chamber fame ( that picture, with names, is my new desktop on my work computer since we were aquired by Solvay ).

    I always get him mixed up with Max Planck ( on the other side ).

    Yes, he is very similar with Planck.

    (and me, if I cut beard)

     

    Incidentally there is no 2015 conference. There was one in 2014, and they are three yearly events, I believe.

    Hehe.

    I meant, our own forum scientists conference.. :)

  6. Then there's going to be an ego meltdown in academic science community over the next few years.

     

    Oh, really? How come so.. ?

     

    If we measure now object with mass m to be accelerated by force F to speed v, will it change?

     

    When you're just a big puddle of wrong, we'll still love you.

     

    Only Jesus, would say so.. Are you Jesus? :)

     

    Anyway, it was very nice. We should love even people with who we disagree.

  7. Hello!

     

    Android and entering floating point numbers. With inputType=numericDecimal

     

    Has anybody found any sensible solution to this madness.. ?

     

    Google has not done anything since at least 2009 AFAIK.

     

    This for instance

    http://stackoverflow.com/questions/12780125/soft-keyboard-with-comma-instead-of-dot-for-decimal-separator-in-android

    doesn't work on my Samsung Galaxy S5..

     

    Tried

    input.setKeyListener(DigitsKeyListener.getInstance("0123456789.,"));

    and the only thing it did, changed "." (dot) key on keyboard,

    to ".-,+", but it's just visual (!),

    not having any impact on entered characters in text view field..

    (still not able to enter comma character on the phone).

     

    The only thing that really works is ignoring "numericDecimal" and going with "text" inputType...

     

    Best Regards!

     

    ps. If you're UK/USA citizen you will probably have no idea about what I am talking about...

    But as you can see on the map (middle of page)

    https://en.wikipedia.org/wiki/Decimal_mark

    https://en.wikipedia.org/wiki/File:DecimalSeparator.svg

    It's affecting at least half of human kind..

     

  8. In fact, classical mechanics predicts a second electromagnetic wave is emitted from compton scattering that has twice the compton scattering frequency. This emr is twice the frequency, but *extremely* weak.

    Double frequency would mean double energy.

    Then it would violate energy conservation...

     

    There is no such thing as "Compton scattering frequency".

    Scattered electrons and scattered photons vary by energy/frequency. Complement each other.

    If electron takes more, photon takes less. And vice versa.

     

    However there is Compton frequency, unique fC=1.23559*1020 Hz.

     

    If you multiply fC by Planck const:

    1.23559*1020 Hz * 6.626069*10-34 J*s,

    you will get energy of electron:

    8.8710459571-14 J,

    divide by c2:

    8.8710459571-14 J / 2997924582= 9.11*10-31 kg

    to get rest mass of electron...

     

    Hopefully soon this will be confirmed, putting classical mechanics back where it belongs.

    It's in the right place.

    In primary school physics lessons.

     

    I wish learning would start from photons,

    then via pair production go to electrons and positrons,

    then further to protons and antiprotons,

    then further through fusion to isotopes, radioactivity.. It's in chronological order of how particles are created..

    and at the end we can learn classic physics with it's averaging quantum world..

  9. "An extra hour a day of television, internet or computer game time in Year 10 is linked to poorer grades at GCSE, a Cambridge University study suggests. "

     

    Premature assumption.

    It depends on what else kid would be doing instead of watching TV/monitor of computer.

    Also watching f.e. MTV/cartoons versus watching Discovery Science, Animal Planet etc. channels..

  10. It will probably follow Gaussian optics

     

    [article]

     

    Isn't about how light is propagating through transparent/semi-transparent medium, such as water, glass, etc.. ?

    "we would find that a Gaussian source distribution remains Gaussian at every point along its path of propagation through the optical system."

    Vacuum in cosmos is not quite "optical system".

     

    Obviously photons going though medium will be reflected, or absorbed. That's why we can see laser beam in water. Reflected by medium photons stop being part of original laser beam.

    In perfectly ideal transparent medium, laser beam would remain invisible.

  11. You can see for yourself what happens with a standard construction laser.

     

    Point the laser in some safe but convenient direction.

    Move a target along in the beam.

    The laser line will impact the target as a small disk of light.

    This diameter of this disk waxes and wanes as you move the target along in the beam.

     

    When using such as laser for levelling or alignment purposes you need to take this phenomenon into account.

    It's normal inverse square law.

    https://en.wikipedia.org/wiki/Inverse-square_law

     

    Actually, this experiment is basically different from Silvertooths experiment because the standing wave is locked to the mirror. Yet the author reported that the voltage at the SWD varied as the linear stage was moved. This experiment even violates fundamental accepted knowledge of elementary physics. It implied that the voltage at the SWD will vary as the linear stage is moved relative to the laser, even if there is no relative motion between the mirror and the SWD.

     

    Actually, in the experiment, the mirror is dithered and the change in phase of the AC voltage at the SWD is observed. Since the mirror and the SWD are co-moving, the phase of the SWD voltage should not vary as the stage is moved relative to the laser.

     

    Am I right or where did I go wrong? Please help in pointing out the problem. Thank you for your time.

    I draw you image, and take photo.

    See attachment.

    post-100882-0-23907300-1441371336_thumb.png

    Laser has initial energy E0, or intensity I0,

    after traveling distance d0, it's reflected from mirror, and reverse direction back to source,

    and travel distance d1,

    and hit detector. Traveling total d=d0+d1 distance.

     

    In second example light is traveling d=d2+d3 distance.

     

    Distance between laser and detector remain the same x.

     

    Yet another version of it, is when distance between detector and mirror remain the same (move together), and only distance from laser and mirror changes.

  12. The transition between when the Earth looks flat from above and when you are in a sufficient distance to see it is round and the transition between a blue sky and depths of space. Is there any simulation, where you could see the Earth from above while getting further away from it?

    Here is recording from on board camera on home made rocket

  13. The pension must be prohibited the way they are today.The pension model is socialist.The pension insurance is collecting in funds which invested the money in companies and the risk is distributed among all who paid this insurance.The people must not paid pension insurance but the money they receive they must to invest at their own risk.In this way public companies will be motivated to earn more profit.Not having such insurance people will be much interested where to invest their money whether In stocks,bonds or land to became a farmer after years.Now people with this pension system are irresponsible.They are so irresponsible so that they do not want to have even children.They think that somebody else must pay their pension in future.The public companies shall also be more concerned in making money.Destroying this pension system people will be motivated to start small businesses and to became farmers and they shall wanted to have children.This pension system is in favour to big companies because they get the money of the pension funds.

    Unlike others I won't ask what pension system you're talking about, because it's perfectly clear here.

    There is dozen of on-line calculators where employer/employee enter gross salary,

    and they will calculate how much of money will go to retirement funds, ill-person pension funds (don't know how to translate it better, this includes disabled persons), etc,

    and how much employee will get in hand net salary.

     

    Example, copied from calculator:

    Gross salary 3750.00

    Retirement insurance 366.00

    Pension insurance (disabled persons included) 56.25

    Ill-person salary insurance (disabled persons excluded. If you're ill and temporarily unable to work, it'll be used to pay your salary) 91.88

    Ill-person insurance (your own, salary for doctors, hospitals etc.) 291.23

    Income tax 265.00

    Net salary 2679.65

     

    You missed the point of this system.

    What to do with:

    - ill persons temporarily unable to work

    - ill persons permanently unable to work (disabled persons).

    - mentally ill persons.

    - people unable to have children (you're mentioning children in sense that children should take care of their parents and grandparents in future. People unable to have them will be left alone in your system)

    - people who don't have children

    - people who currently are taking pension/retirement

     

    If you want to destroy currently existing system, all these people who are currently using this system will be literally screwed and left without money..

    They were participating in system for decades, and now some georgi zlatev comes, and want to take their money.. ?

     

    People, at least majority, are not responsible. (see how many famous and intelligent (or rather better word: educated) "invested" in Madoff fund)

    They will spend all the money they get now. And will be left with nothing in future.

    Which would be serious problem for goverment, flood of grandpas/grandmas begging for money and food on streets, searching food, bottles and Aluminium cans in trashcans..

    Don't bring USA here in Europe.

  14.  

    I thought anyone who understood programming would know this. But apparently not.

     

    Since the beginning of this discussion, I am *exclusively* talking about execution time, time spend by CPU processing data.

    It's obvious that writing reg expression handling code is easier for programmer, spend less time on doing so, than making the same string comparing code by hand.

     

    If you claim something else, then prove it.

    Measure time spend by cpu, by getting time in microseconds/miliseconds, then execute some reg expression match(), compiled or not, 1000 times repeat, get time again, subtract.

    And we will know how many miliseconds/microseconds is taken by single match.

    Then do the same with manual code finding same pattern.

  15. But now imagine that you need to search for 100 variations of your "some string". A regex will be much, much faster.

     

    Make source code proving your words,

    I will make counter-code, proving my words.

     

    Your case could be only true, if somebody for purpose, scuttle it.

    f.e.

    strings to search are:

    xyzabc

    xyzbcd

    xyzcde

     

    (and reg expression something like (.*)xyz(abc|bcd|cde)(.*) )

     

    now C/C++ coder could use:

    if( strstr( buf, "xyzabc" ) ||

    strstr( buf, "xyzbcd" ) ||

    strstr( buf, "xyzcde" ) )

    {

    // found!

    }

    (this is WRONG, because each time its going from start of buffer to the first occurrence, cpu is passing through the same chars multiple times)

     

    Instead he should do (something similar to):

    t = strstr( buf, "xyz" );

    if( t != NULL )

    {

    t += 3;

    if( !strncmp( t, "abc", 3 ) ||

    !strncmp( t, "bcd", 3 ) ||

    !strncmp( t, "cde", 3 ) )

    {

    // found

    }

    }

     

    ps. I am using reg expressions. Where I find them useful. f.e. made process monitor, and file monitor, which had filters implemented as reg expressions (filter control in GUI). So they displayed entries matching pattern.

    But I also showed example of job where reg expressions showed weakness..

  16. Speaking from both the development tools side and as a user, this is not always true. A regex can often be much more efficient than equivalent conditional code.

     

    Basically, nonsense from cpu/performance point of view.

    It's physically not possible. And you should know it exactly from physics.

    Native code is less instructions to execute (optimized by C/C++ compiler), taking less time, than reg expression compiled code.

     

    Doing C++ code:

    int length = strlen( buffer );
    for( int i = 0; i < length; i++ )
    {
       if( !strcmp( buffer + i, "some string" ) )
       {
           // found sub-string
       }
    }
    

    or simply:

    if( strstr( buffer, "some string" ) != NULL )
    {
       // found sub-string
    }
    

    will, and always be, much faster than equivalent reg expression.

    Compiled to machine code or JIT, can in the ultimately the best scenario just reach 90%-95% of normal code speed. And never exceed nominal code.

     

    You should not compare *Python* conditional code, to C/C++ conditional code. That's where you made mistake.

    *Python* (or other scripting language) conditional code might be indeed slower than same done by reg expression.

    But C/C++/assembly will never be slower.

    C/C++/assembly is not interpreted, as Python..

     

    You wonder why your program with GUI, progress bars, logs, etc. was so slow...? I don't think it is anything to do with regular expressions!

     

    I knew, (I knew!) you will point it out when I wrote about GUI. Typical Linux user-programmer.

    Sounds like you have no experience in .NET Framework C++ GUI coding.. Because it's (unlike many GUI toolkits around) extremely fast (at least listview).

    I can make listview items counted in thousands per second, without any slow down, to the main code.

     

    See attached project. Compile it on your machine.

    BenchmarkListView.zip

    It's benchmark adding items to listview.

    Adding 10,000 listview items, takes 125 miliseconds, on my Core i7 machine.. with update_is_faster = true;

    (80000 per second)

     

    Adding 1000 listview items, takes 93 miliseconds, with update_is_faster = false;

    (10752 per second)

     

    Single threaded GUI.

     

    Handling GUI didn't introduce even 0.1% of slowdown..

    Progress bar even less (it's updating every 1% of progress, where 300,000 files is 100%, 1% is 3000 files..).

    I stopped it after waiting 10-20 minutes, it didn't even reach 1% to update..

     

    BTW, I used exactly the same logging to GUI listview with reg expression parsing code, as with manual conditional parsing code. It should be hint to you.

  17. If you would have plentiful of data to process, counted in MB or GB, using reg expression could tremendously slow it down.
    Once I had project (.NET Framework Managed C++, I don't write scripts..),
    download 250-300 thousands files from net, save in folder, 20-100 kb per file, ~20-30 GB could be total,
    and find some data in HTML file loaded from disk.
    Linux-loving-neighborhood was saying "do it using reg expressions!" (he is obviously great fan of it). So I did try it..
    (he was doing this project in Python, and I was doing in .NET Framework C++, such little competition)
    I am GUI-loving person, so I am adding everywhere progress-bars running on 2nd thread etc.
    And listviews where are logs displayed to show me what is going on in real-time *)
    After processing a few hundred files, I was shocked, it was nightmare performance, I canceled.
    Otherwise would have to wait weeks to finish with all files..
    Replaced reg expression, which was extracting data from HTML, by string search some <tag>, which was unique, prior my data,
    then find closing </tag>. And processed what was inside by hand.
    Guess what. Literally it started working "1000 times" faster...

    *) This is important.
    Linux-loving-guys are running their scripts, with logging to file, not to screen typically, and going doing other stuff.
    And then returning when job is done, periodically checking.. They might not even realize stuff they coded could run 1000 times faster, if would code it differently..

     

    A serious answer to this is flexibility. We have assumed that the numeric entries all begin with a digit. But what if there are also negative numbers? Or if some of the numbers are written with no digits before the decimal point? Or there are spaces before the number? And the spaces could be tabs and/or other white space? Or there are blank lines to be skipped? Or there are comment lines to be ignored as well?


    That's job for String.Trim()/String.TrimStart().
    To check whether we have correct float, there could be used Double.Parse()/Double.TryParse().
    .NET Framework C#/C++.

    array<String ^> ^lines = File.ReadAllLines( filename );
    for each( String ^line in lines )
    {
       line = line->Trim();
       if( line->Length() == 0 ) continue;
       try
       {
          Double x = Double.Parse( line );
       }
       catch( FormatException ^e )
       {
          // row not number or so
       }
    }

    I would spend more on searching reg expression tutorials to learn what to enter than writing this reply..

    And for anything more complex than the initial example, a compiled RE will quickly become more efficient than the conditional code.


    More efficient to code (less time spend on programming), not more efficient for cpu.

  18. Well, I am dealing somewhat with lower power,

    What power?

    I said voltage..

     

    If you want 5 V, then take Zener 6 V, that's no problem at all.

    I used 15 V as an example for protecting 12 V nominal voltage circuit.

     

    Why is it better to use a fuse that could blow up instead of a charge regulator? Just more cost effective?

    I was describing general way of protecting vulnerable circuit, used in any case.

     

    Voltage regulators are using Zener diodes to not allow too high voltage reach circuit.

     

    Read this f.e.

    http://www.electronics-tutorials.ws/diode/diode_7.html

     

    and this

    http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/zenereg.html

    about Zener regulators.

     

    Instead of buying regulator you can build your own at microscopic cost.

  19. The new versions of python are I remember a python that couldn't count and complained on big files.

    If you will read big file in chunks, as everybody here are suggesting, there should be no problem.

     

    It still can't count. Why adding 0.0001 onto 0 up to 10 returns 9.994699999999 I have no clue.

    I can't check this, to confirm or deny. But such errors are everywhere, in all codes.

    It's just a matter of precision (any code will have issue while using IEEE 32 bit at 7+ digit after floating dot)..

    Math library issue most likely. It could be also issue with printing float, or float to string parsing routine.

     

    If it's really an issue (causing problem with your own code, not just theoretical talking), why don't you use integers and divide by 10000 at the end?

     

    Like in C/C++ code:

    int x = 0;

    int y = 1;

    x += y; // counter

    float x1 = (float) x / 10000.0;

    printf( "%f\n", x1 );

     

    (integer 10000 = 1.0 in float)

     

    I have no idea how they made blender out of it.

    Blender is written in C/C++.

    Such apps have special extension for Python, which can be loaded/imported in script, and Python can execute its functions, controlling the main app.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.