« first day (157 days earlier)      last day (3054 days later) » 

12:00 AM
2
A: Cover up zeroes in a list

DennisCJam, 11 bytes q~{1$e|}*]p Try it online.

 
weird:)
 
possibly because CJam is stack-based and Pyth isn't?
 
Maybe
I thought being stack-based would be an advantage
Ir's too late now :-)
 
It could be a topological thing. How many opearations you must do to perform a given kind of task
 
i don't know enough about either language to really know
 
12:02 AM
@LuisMendo there's always room for MATL++;)
 
@AndrasDeak Sure! Let's first get it started for real, and then we'll worry about improvements :-)
I plan to make it official in maybe two weeks
or less
 
@LuisMendo don't look at me, I'm just the chimp behind the typewriter:D
 
@AndrasDeak But just because you want it that way :-) I know you'll bite the code golf bait someday
 
@LuisMendo I guess so. Once I'll have enough guts to ignore the kinds of Dennis:P
and start understanding stack-based languages
 
@AndrasDeak Efficient or not, having a stack is cool. It makes you think differently about how to arrange data
And for certain problems it is indeed very efficient
 
12:06 AM
Sure, that's why I'll need to understand it:D
 
Feels like domino pieces falling, so to speak. It's nice
 
I never said it's a bad thing. Heck, I don't even have the necessary perspective to be the judge of that.
 
Well, there's a very nice MATL spec waiting for you... it even has your name in it :-P
 
:D I'm looking forwad to it:)
But now, time for bed. Have fun, guys:)
 
g'nite @AndrasDeak
 
12:34 AM
All MATL examples up to now end with a D function (display). I guess MATL should automatically print at the end (either the top or the whole stack), as CJam does. That would save 1 byte
 
is the rest of the stack normally consumed in your examples?
it might be good to have multiple outputs for multiple vectors, say, but if it has garbage left on the stack then that wouldn't be good
 
That's the point. I initially decided not to do implicit printing to prevent garbage from showing. But looking at all examples up to now, all print the top element at the end, and in all but two that's the only element left. In those two examples there's only one unwanted element (the ont not at the top), which could be removed in two characters:
w      % swap elements in stack
x      % delete
@beaker ^^
Of course the D and E display functions would be kept, so you can print before the end of the program
 
1:02 AM
@LuisMendo sounds like a winner then
 
 
11 hours later…
11:52 AM
0
A: Crack the safe!

flawrMatlab 171 bytes The input should be a 2d matrix, so you would call it like c([1,1,1,1;0,0,0,0;0,0,0,0;1,1,1,1]) (semicolons start a new row). This function just bruteforces all possible moves, so we get a runtime of O(2^(n^2)). How it is done This is done by choosing all possible ways to fil...

 
 
6 hours later…
5:25 PM
I love arguing with n00bs.
-1
Q: Winner and inverse filter

Anirban SanyalA photography is taken out of a side window of a car moving at a constant velocity of 80 km/hour. Why is it not possible to use an inverse or Wiener filter in general to restore the blurring in this image ? Describe it briefly.

We're not here to do your homework. — rayryeng 9 hours ago
No, for your information that's not how this site works. My 50K reputation above you mere 2 begs to differ. This site is about answer programming problems when you have shown effort in trying to solve your problem. We are NOT a do-your-homework service nor is this doyourhomeworkoverflow.com. Please read this page on how to write a proper question: stackoverflow.com/help/how-to-ask. You can at LEAST phrase your question such that it doesn't sound like a direct copy and paste from your homework assignment. At this stage, NO ONE is going to help you. Guaranteed. — rayryeng 30 secs ago
 
5:41 PM
I'd love to hear more about the Winner filter.=)
 
@AndrasDeak Hi!!!
Using the periodic function I get the following:
It can't be right, can it? @AndrasDeak
 
@flawr :D
But the true answer is that the Wiener filter is used for reconstructing images when the camera is subject to motion or when the lens itself is subject to distortion when capturing images, not the objects in the image.
I would have written an answer if the OP made a bit of effort asking an actual question and not copying and pasting from a homework assignment.
 
 
1 hour later…
7:14 PM
@evinda no, it can't
@rayryeng you're the smuggy smug of smugness
"Describe it briefly", LOL
 
@AndrasDeak I used the u that you and David proposed. Why is there is a mistake?
 
@evinda because you made an error
 
@AndrasDeak At the approximation?
 
@evinda with the exact solution
although I'm not sure...it might also depend on the value of beta
it might be that your numerical solution is too large
 
@AndrasDeak For beta=1 I get the following:
pastebin.com/E1eEuxdn That's how I defined the exact solution. @AndrasDeak
 
7:36 PM
In general I think you need something like floor((x-2*t)/(b-a)), and there might be a sign problem
what's the formula for your exact solution, again?
@rayryeng and then you have the effect of a roling shutter:P
 
I looked for it again and now I got that u(t,x)=u_0(floor(2t-x)-(2t-x)) @AndrasDeak
For beta=1 I get now the following:
for beta=100:
 
well that seems better, doesn't it?
I suggest using a different starting function: use uxact(x,0) as the initial conditions, that might make a difference
I'm not sure
 
@AndrasDeak And I get the following errors:
>> [er]=wind(0, 1, 40, 1, 100, 100)

er =

0.0227

>> [er]=wind(0, 1, 80, 1, 200, 100)

er =

0.0108

>> [er]=wind(0, 1, 160, 1, 400, 100)

er =

0.0047

>> [er]=wind(0, 1, 320, 1, 800, 100)

er =

0.0019
@AndrasDeak This u_0 is given... I didn't take it by myself...
@AndrasDeak There should be still an error at the exact solution since -ceil(x)=floor(x)
 
7:54 PM
@evinda I don't understand your last message
 
Does anyone here have an idea on how to detect the number of limit points in a sequence?
 
@flawr umm...on paper, I guess?
 
Nope, with a computer program=)
 
ooh
 
E.g. The logistic map. x(n+1) = r*x(n)*(1-x(n))
Oh, thank god we have fourier=)
 
7:59 PM
@evinda plot both for t=1/2 and I think we'll see why they are so different
 
I get tha above @AndrasDeak
 
@evinda haha, I don't think so
 
8:20 PM
Btw are you a student? @AndrasDeak
 
@evinda nope
 
Do you work in the research-area? @AndrasDeak
 
@evinda indeed
 
Nice @AndrasDeak
@AndrasDeak But isn't now the exact solution correctly defined?
 
not necessarily
you have to double-check the definition, and make sure that for every t, the values of the exponents are the same
only reordered in your domain
so if it's defined properly, then you get the same values of the exponent but in a different order for various values of t
are you sure about u(t,x)=u_0(floor(2t-x)-(2t-x))?
 
8:38 PM
@AndrasDeak I think that it should be u(x,t)=u_0(x-2t- floor(x-2t )).
 
I think this assumes that b-a=0
 
@AndrasDeak We have b-a=1
 
@evinda OK, though your code doesn't
 
@AndrasDeak What do you mean? a and be are given as arguments
 
yeah, that's what I mean
you should have floor((x-2t)/(b-a)) in there, I think, though I'm not sure
anyway, for a=0, b=1 it should be correct
so how did you implement it again?
and what is the formula for uexact?
 
8:42 PM
function u=uxact(x,t,a,b,Beta)
u=exp(-Beta*((x-2*t)-floor(x-2*t)+(b-a)/2).^2);
end

@AndrasDeak
 
OK this doesn't seem right
you're missing an additional sign
for t=0 the exponent should be 0 at x=1/2=(b-a)/2
so try changing the last term of the exponent to -(b-a)/2
 
@AndrasDeak Oh yes!!! I changed it... ... Now for N_x=160, N_t=400 I get:
This seems right, doesn't it? @AndrasDeak
 
9:17 PM
I created a video of the approximation and the exact solution using movie2avi @AndrasDeak
How can I save it so that I can send it to you?
These are the results that I get for the order:
p1 =

1.0713 1.2123 1.3252
@AndrasDeak Aren't the numbers too great?
 
9:34 PM
@evinda it does
@evinda you could create a gif out of it
@evinda I don't know, since I don't know what and how you compute as "order", and what it should be:P
as usual
 
@AndrasDeak It is a movie that represent the exact solution and the approximation at each time.
 
@evinda I know, I understood that
 
@AndrasDeak I mean the order of accuracy, that is given by the formula log_2(error(N)/error(2N))...
 
@evinda OK, I still don't know what to make of that.
 
@AndrasDeak So should I a make a picture of the solution and the approximation for several times?
 
9:38 PM
but you can create a gif like ths or using this
 
I found it like that: http://pastebin.com/ViJ9fHea
But the order should converge to 1.
 
again I don't know what you're calling an error
we've been through this a dozen times
and please don't try to tell me again, you always fail:P
but I'm really interested in that movie:)
 
@AndrasDeak This time the formula is given
 
@evinda oh, is it?
 
9:43 PM
cool!
and how are you computing it?
and is the order defined with doubled spatial and temporal mesh both?
 
@AndrasDeak http://pastebin.com/fQ4rz2uY
But now I realized that the results converge to 1:
ans =

0.5307 0.6752 0.7978

By accident, I calculated the 2-norm... Sorry!!!
Now I will try to save the movie @AndrasDeak
 
cool, thanks
 
10:01 PM
@AndrasDeak I get this warning message:

??? Undefined function or method 'movie2gif' for input arguments of type 'struct'.

Error in ==> mov at 27
movie2gif(M,{M(1:2).cdata},'test.gif',0.02,0.05,1,inf);
 
because it's a file exchange utility
you have to download it from the file exchange:P
and put it on your path
 
10:22 PM
Where can I find it? @AndrasDeak
 
find what?
 
@AndrasDeak with movie2avi I used the following:

for j = 1: Nt+1;
...
plot(x,xactt,'r',x,Un,'b');
...);
M(j) = getframe;
end
movie2avi(M,'ex3.avi','fps',15)


do I have to change just the command `movie2avi(M,'ex3.avi','fps',15) ` ?
 
Have you tried the help?
I've never used that utility before
and I don't have it downloaded
so hopefully you're at an advantage:P
 
11:07 PM
I haven't achieved it yet.... @AndrasDeak
 
11:18 PM
OK
 
11:30 PM
@rayryeng @excaza @beaker @Dev-iL I'd like your input, I might have found a bug in R2012b and str2func (I know, cousin of eval)
Compare:
f = @(x) 4*x
funtmp1 = str2func('@(x)[sin(x)]');
funtmp2 = str2func('@(x)[f(x)]');
funtmp1(1) %OK
funtmp2(1) %throws error, even though f is in the workspace
 
that doesn't seem right...
 
@beaker are you on octave now?
 
yes
 
Oh, you don't even need the vectors there
simply str2func will fail like this for an anonymous function
I tried looking around but didn't really see any indication of this behaviour
So @beaker you agree that this seems like a bug?
 
@AndrasDeak str2func lines give me errors in octave
@AndrasDeak still looking through the documentation to see why this would be excluded
 
11:38 PM
thanks:)
 
> If you include workspace variables in your string, str2func creates the function handle, but MATLAB throws an error when you invoke the function handle.
function handle is a workspace variable
 
hmmm
shit, you're right
I read that about workspace variables, but I didn't realize that my function handle was that:(
Thanks
 
well, that's the way I read it
@AndrasDeak You're very welcome :)
 
Hi all :D
 
Sorry @rayryeng @excaza @Dev-iL for the false alarm:P
@NiKoLaPrO hi
 
11:42 PM
Hi @NiKoLaPrO
 
@AndrasDeak Yeah, str2func is weird like that: Hey, I'll transform this string into a function handle, but I won't parse it at all.
This is the one case where I'd argue for using eval if the program architecture requires the behavior.
 
@TroyHaskin I can understand that, it's part of what should make it safer I guess
 
@TroyHaskin But even anonymous functions will include workspace variables... I don't get it :/
 
I just didn't realize that it couldn't expand anon functions
 
@beaker I think the choice was made not to invoke the Matlab interpreter because there would be an implicit eval somewhere in the str2func call.
 
11:45 PM
But I hate eval:(
 
@AndrasDeak are you working on that "cell array of function handles" question?
 
@beaker yup
had an almost decent solution
but it was based on str2func, which doesn't work as I want it to work, so I deleted it
 
i'm still not sure i understand that one
 
I could turn {@(x,y,z) f1(x,y,z), @(x) f2(x), @(y,z) f3(y,z)} into @(x,y,z) [f1(x,y,z); f2(x); f3(y,z)], which could have been invoked as an anon function
 
i would think that a vector with the combination of functions to call would be sufficient, right?
 
11:47 PM
@beaker you can't do that with a vector, only a cell
you can only vectorize after evaluation
 
you'd have to loop it to do it with a vector
 
unless you do something nasty
 
I would've put effort into that question if the OP gave a concrete example of the intended output (like "in the case of a Hermite basis, f would be ..."). I could've asked, but I chose to be lazy and cantankerous.
 
@TroyHaskin ;)
I got that way yesterday with that precision question
I relented after the OP gave up :))
 
@beaker well there it wasn't even clear that OP wasn't an idiot
 
11:51 PM
@AndrasDeak that's the problem... even if he was, he could have had a legitimate precision problem. we just couldn't find out.
 
yup...but this OP is clearly intelligent and apt
 
yes, i just don't know how to fix his problem :)
 
Especially since he already knows what to do, he's looking for additional options
I give up
 
@beaker :)
@AndrasDeak Gotta love the internet.
 
@TroyHaskin you mean being full of all those smart people, or being full of all those kind people like me?:D
 
11:58 PM
@AndrasDeak I mean not knowing if the problem is due to the short-comings of communicating via only text or if the person is just dumb as dirt.
 

« first day (157 days earlier)      last day (3054 days later) »