|
Again with the logic issues!
It's a hideously inefficient and imprecise way to make a picture, but, for whatever peculiar reasons, he and his parents find logic in this inefficiency and imprecision (which will absolutely not get him into art school).
Are crayons banned, in his house, to prevent him drawing on the walls (which is tricky to do with Rubik's cubes)?
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Pfft ... he's got a cheat sheet in front of him. He's a good "cuber", but probably a lousy artist (software)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
In C# I took my lex from .045 msec to .028 msec by changing the lists i was using to arrays.
This despite the fact that there were no reallocs happening in those lists (i already checked)
_Fiber[] currentFibers, nextFibers, tmp;
int currentFiberCount=0, nextFiberCount=0;
is simply faster than this
IList<_Fiber> currentFibers,nextFibers,tmp;
Conventional wisdom is lists are about as good as arrays perfwise as long as your capacity is high enough.
Conventional wisdom can get bent
Real programmers use butterflies
|
|
|
|
|
That probably hasn't been true from the time CPUs got caches. Stroustrup himself says as much.
Mircea - I would put a smart quote in my signature if I wouldn't be so lazy and if smart quotes wouldn't be so overused.
|
|
|
|
|
Well, Microsoft's .NET soothsayers would tell him otherwise, but he's right.
Adding: After reading that link it looks like Bjarne and I aren't talking about quite the same thing.
Basically if this was C++ and not C# I'd be complaining that arrays are faster than std::vector, not lists
Real programmers use butterflies
|
|
|
|
|
Reference Source. Makes some sense. You're saving 17 microseconds and all of those checks and calls cost some amount of time. My thoughts have always been that lists are better as a default because you can abstract them (e.g. IList<t>) and you don't need to worry about bounds, while arrays are better when optimizing critical sections for performance (indirection has a cost).
|
|
|
|
|
This is one of the few areas where i need every microsecond i can get.
It's a virtual machine that runs a regular expression match as per here:
Regex as a Tiny "Threaded" Virtual Machine[^]
It seems trivial but this code itself ends up being part of an inner loop of an inner loop when it's being driven by a parser.
It needs to be as efficient as it can be.
My hope in using lists initially was that the framework would minimize the impact of bounds checking in the ngen'd corlib beyond what arrays already do internally but i guess that was wishful thinking
Real programmers use butterflies
|
|
|
|
|
array is not only supposed to predictively as fast as foreach loop on list
but I am not sure I quite believe it...
The difference is only very minor though.. and would be important if your statement each iteration is quite minimal...
|
|
|
|
|
foreach itself has some performance issues as it requires object creation.
I need to eke every clock cycle I can out of this routine.
Normally I only optimize when i can make algorithmic improvements, but my algo is already tight for what it does.
Sometimes even in the days of powerful computers, we still need to bit twiddle every once in awhile. Lexer routines are a good example of where.
Real programmers use butterflies
|
|
|
|
|
The goal of this is to produce a small program to solve a physical problem with numerical data. An electron of
charge −e and mass me is moving at a speed v(t = 0) = vex in the plane Oxy between the two plates of a capacitor.
The field is given by E= Eey. The only force is Lorentz F=qE. Plot the trajectory of this electron.
Python code: plot the trajectory of this electron; use matplotlib.pyplot to plot and scipy.integrate.ode
to solve the problem.
|
|
|
|
|
Wrong place to post this: as it says in red at the top of the page you need to be here: Ask a question[^]
But ... we aren't here to do your homework anyway. We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
So if you do post this in the right place, you'll need to explain all of that, or you won't get help - we do not do your homework for you.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I didn't understand scipy part, how can I use it? And what for?
|
|
|
|
|
Easy.
SciPy is a free and open-source Python library used for scientific computing and technical computing. SciPy contains modules for optimization, linear algebra, integration, interpolation, special functions, FFT, signal and image processing, ODE solvers and other tasks common in science and engineering. (copied from wikipedia.org)
The solution to your problem might need to use one of the models in SciPy.
|
|
|
|
|
I suspect that you will find your tutor covered that library in your last lecture - they normally do just before setting homework requiring it ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
tutors, smuters ...I've got CodeProject (or that other one).
after many otherwise intelligent sounding suggestions that achieved nothing the nice folks at Technet said the only solution was to low level format my hard disk then reinstall my signature. Sadly, this still didn't fix the issue!
|
|
|
|
|
You are well tuned in to modern student lack-of-thinking.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I got my Pike Virtual Machine for running regexs coded and it's a fun little widget;
L0000: split L0001, L0008, L0020, L0024
L0001: save 0
L0002: set "A".."Z", "_", "a".."z"
L0003: split L0004, L0006
L0004: set "0".."9", "A".."Z", "_", "a".."z"
L0005: jmp L0003
L0006: save 1
L0007: match 0
L0008: save 0
L0009: split L0010, L0012
L0010: char "0"
L0011: jmp L0018
L0012: split L0013, L0014
L0013: char "-"
L0014: set "1".."9"
L0015: split L0016, L0018
L0016: set "0".."9"
L0017: jmp L0015
L0018: save 1
L0019: match 1
L0020: save 0
L0021: set "\t", "\n", "\v", "\f", "\r", " "
L0022: save 1
L0023: match 2
L0024: save 0
L0025: any
L0026: save 1
L0027: match -1
That lexes a regex with an id (match 0), integer (match 1) or whitespace (match 2)
My little compiler generated that when I called this:
int[][] prog = Regex.CompileLexer(
@"[A-Z_a-z][A-Z_a-z0-9]*",
@"0|(\-?[1-9][0-9]*)",
@"[ \t\r\n\v\f]"
);
The instructions are encoded as an array of ints per, while the overarching instruction stream is int[][]. This way i can pass it around without requiring dependencies, and I can implement the VM/interpreter in an outside library without requiring a reference to an Instruction class or something.
The thing that's cool about this machine is it's cooperatively threaded. I'm tickled about that. Split jumps to multiple locations "at the same time." so it's concurrent. In reality this was a neat trick wherein i interleave the execution of each thread so i don't have to backtrack over the input.
It's the coolest project I've made this year, and the article is already getting underrated at codeproject.
I think people ph33r regex.
Still, it's so much fun.
Thanks @BillWoodruff for finding my bug that inspired my misguided .NET unicode rant
Real programmers use butterflies
modified 18-Jan-20 11:27am.
|
|
|
|
|
honey the codewitch wrote: and the article is already getting underrated at codeproject.
Yeah, that really surprised me, as I thought what you're doing here is really the coolest thing since sliced bread. Oh well, go figure.
|
|
|
|
|
Thanks. I really think it's the regex. I think some people just hate it.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: I think some people just hate it. Not as much as perl.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
I used to hate regex, and then one day the Regex angels came to me in a vision and I understood!
|
|
|
|
|
I had a similar experience with COM
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: Thanks @BillWoodruff for finding my bug that inspired my misguided .NET unicode rant
Good ol' Bill!
|
|
|
|
|
Jonathan Allen (InfoQ) writing on tiered compilation in .NET 3.0:Quote: the runtime initially produces quick to compile but non optimal JIT code as needed and then executes it. Then in the background the runtime analyzes the context and IL code to determine if a more optimal JIT solution can be achieved. If so, it recompiles the IL code and swaps out the slow JIT path with the optimal JIT path. I'm sure there's some additional complexity in how that's achieved, but that's the basic idea. For static class initializers and static readonly field initializers, the runtime will produce first pass code that takes the init lock. That protects against the initializers ever running twice. That locking also has a runtime performance penalty. So, once the initializer runs once, the optimizer will simply produce new optimized accessor code paths that don't do any locking anymore! [^].
I find Allen's in-depth coverage of C# and .NET developments, future features, etc., the most useful of any current source ... okay, okay ... Kent Sharkey, Scott Hanselman, Mads Torgensen, and the Nabobs and Hierophants of CodeProject are equally stellar phenomena
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Jonathan Allen wrote: So, once the initializer runs once, the optimizer will simply produce new optimized accessor code paths that don't do any locking anymore!
This makes me wonder what sort of jit magic happens with synchronizing awaitable methods.
Real programmers use butterflies
|
|
|
|