My reference is D. Goldberg's paper "What Every Computer Scientist Should Know About Floating-Point Arithmetic"."Numerical Computing with IEEE Floating Point Arithmetic" is a fantastic book on the topic, quite short and easy to read. I highly recommend it to all programmers.
I see. But the issue is that Windows will forbid you to remove the file as long as there's someone "using" it. It can be an unclosed file descriptor somewhere, or something like this. There's no easy way around it, the first task would be to
Programming is about encountering difficult problems and solving them. You can have something explained to you 100 times, but until you've encountered it yourself it doesn't really sink in.
Presumably your teacher has explained about imprecise represntation of floating point. Now you have an actual experience to back that up
Good catch, but what had me is that os.remove on a directory return "Access denied", if I'm not mistaken, and not "File being used". There may be two issues there?Actually in this case, i think the issue is you need to use shutil.rmtree to remove a directory tree. os.remove doesn't work for directories, and os.rmdir only works for empty directories
Want to take chances he thinks %.1f display the truncated value and not the rounded one? ^_^It's literally just the absolute basics.
Good luck ^_^ That's an interesting subject (and things a programmer should know if he deals with fp values) although sometimes it's insanely complicated.I am now of course reading about the float accuracy stuff because I actually want to know
Anyone can write awful an unreadable formulas, unfortunately (and I grant you that this set is complex... there's even mess with indexes and exponents).I imagine it would be easier to everyone if, at least in addition to the math definition, people write stuff in plain english, or maybe pseudo code for more algorithmic stuff.
Math can be imprecise, too (and in this case, it is... at the very least, the double usage of index k in the definition of adjacent groups is awful, I think)Wittgenstein helped us understand that language is imprecise and the only hope is precise, artificial languages. That's what math is!
Anyone can write awful an unreadable formulas, unfortunately (and I grant you that this set is complex... there's even mess with indexes and exponents).
That being said, I'm not sure using an english sentence instead of "argmax" is better. And at the end, the thing that bothered me most is actually a sentence, the "adjacent groups" (OK, that's also because the "formula" that explain the idea is awful).
I think that the main problem here is that
- it doesn't explain what the hue histogram on a neighborhood of the pixel is
- the fact that they factorized two things into a single formula (hue AND gradient)
doesn't help.
Most of those issues come from the fact that articles like this are length-constrained, it's often awful to put a whole method in 4, 8 or 10 pages, including state of art, tests, bibliography, etc :/
Do you want pseudo-code for this?
It's a precise language imprecisely usedMath can be imprecise, too (and in this case, it is... at the very least, the double usage of index k in the definition of adjacent groups is awful, I think)
Good catch, but what had me is that os.remove on a directory return "Access denied", if I'm not mistaken, and not "File being used". There may be two issues there?.
I agree... that's what I was talking about "adjacent groups", and the " i_{k+1} = i_k +1 mod 8 ". It's really misleading.What bothered me the most was the definition of c and I\c and formulas (3).
Depends... More pages are more expensive. Often, you CAN add pages, but you'll pay for them (when the normal number of pages is "free" if your article is selected).I don't understand why constrain the length of an article.
Pretty sure you can, but you may need to have some experience in the field. Should you really not understand something, the mail of the authors is there for a reason...If I can't understand X, what value the article has to me?
I know, I went through this, but I found installing libraries and dependancies like Boost far, far more bothering than any research paper ^_^But for someone who is starting in the area, it is really frustrating.
With a grain of salt, I may have misunderstood:Anyway, yeah a pseudo-code would help immensely.
for each (x, y) pixel
create a table T of size 8, initialized with 0
for each (x', y') pixel close to (x, y)
Compute the direction of gradient at (x', y')
Add 1 to the table in the cell corresponding to the
direction (N, NE, E, SE, S, SW, W, NW) of the gradient
for a in 0..6
for b in (a+1)..7 (<- for all partitions of the table)
find the highest value *h1* in T[a:b)
and the index *i1* of the corresponding cell
find the highest value *h2* in T but not in T[a:b)
and the index *i2* of the corresponding cell
compute v[a,b] = exp(-abs(h2-h1)) * abs(i2-i1)
return the minimum among all values v[a,b]
from operator import itemgetter
def DualIndexAndMax(table, rng) :
return ( max( (e for e in enumerate(table) if e[0] in rng), key=itemgetter(1)),
max( (e for e in enumerate(table) if e[0] not in rng), key=itemgetter(1)) )
def GenRanges() :
for a in range(7) :
for b in range(a+1, 8) :
yield range(a, b)
from math import exp
def GenValues(table) :
for rng in GenRanges() :
((i1, h1), (i2, h2)) = DualIndexAndMax(table, rng)
yield exp(-abs(h2-h1))*abs(i2-i1)
def DealWithTable(table) :
return min(GenValues(table))
for each pixel (x, y) :
compute T for the pixel (x, y)
call DealWithTable(T)
add the result to an accumulator
I just checked, os.remove on an empty directory indeed return winerror 5 (access denied) and not winerror 32 (file in use).os.remove is probably implemented with the DeleteFile win32 api. It doesn't say on the documentation what error code it returns if you try to delete a directory, but ERROR_ACCESS_DENIED wouldn't suprise me one bit, it gets used more than it should
I'll grant you that, but you can get the same precision with natural language since you can always describe precisely the mathematical notation in natural language ^_^ (although it's tricky... I've had a blind student in my math class when I was a student, we had to precisely describe every equation, that was difficult and exhausting, but also a great exercise, in fact).It's a precise language imprecisely used
Alright thanks guys. I will see if shutil.rmtree works and report back when I can let's say in directory /test/ there are multiple folders all with files contained within. Call them folder A, B... Etc and I want to get rid of /test/B. So shutil.rmtree('/test/B/') should hopefully work then?Actually in this case, i think the issue is you need to use shutil.rmtree to remove a directory tree. os.remove doesn't work for directories, and os.rmdir only works for empty directories
I'd rather use shutil.rmtree('test/B/') after being sure you're in the correct directory... Why an absolute path?Alright thanks guys. I will see if shutil.rmtree works and report back when I can let's say in directory /test/ there are multiple folders all with files contained within. Call them folder A, B... Etc and I want to get rid of /test/B. So shutil.rmtree('/test/B/') should hopefully work then?
stuff
I hope I'm not wrong, but if It can help, I'm happy...Dude thank you so much. This is super helpful. I actually understand now.
They give different estimation of "harmony" in the picture... harmony of color and harmony of "directions". I haven't read the full paper, but I think they use both.Just one more thing that wasn't super clear, the gradient direction and the part of the hue circle are interchangeable?
Depends on you, and which parts of C++ you'll want to use (it's quite huge).Transition from Java to C++, how difficult is it?
Not really, if you jump directly into C++X11 (or 14) and intelligent pointers.I reckon the pointers and the lack of auto garbage collection will be tough.
Edit: now that I think about it, I'm wondering what you do when the neighborhood of a pixel only have white/gray/black pixels, for which the hue is undefined, or when the gradient norm is null... There's some holes in the algorithm you'll have to fill :/
But the H value has no meaning if S=0 or V=0... It works, but I don't like the bias it add...They convert the image to HSV before, so I would guess they would divide the values, as in divide the values from 0 to 255 (or however many bytes is used to represent HSV) in 8 groups.
#include <stdio.h>
#define PI 3.141592654
double area_of_circle( double radius )
{
static double largest_area = -1.0;
double area;
area = PI*radius*radius;
printf("The area is %lf\n",area);
if( area > largest_area )
{
printf("This is the largest area so far!\n");
largest_area = area;
}
else if( largest_area > -1.0 )
{
printf("I've seen bigger circles\n");
}
return( area );
}
int main()
{
area_of_circle(1.0);
area_of_circle(5.0);
area_of_circle(2.0);
return 0;
}
If the question is about the reason, it's because the idea is to remember the largest area ever encountered by the program.1) Why isn't largest_area set to -1.0 the second time the function is called?
In one run of the program, it'll remember the value from the last call.2) When you run the program a second time, will it remember the largest area from the previous run? Why or why not?
else if( largest_area > -1.0 )
else
#define PI 3.141592654
const double PI=3.141592654;
Smile!Smile!Smile!
Smile!Smile!
Smile!
I'm guessing some people here has seen that Quora post where somebody asks how to print:
and a lot of people give him really inane answers that are technically right. Well I recently figured out that my Organization of Programming Languages professor is the top comment.
https://www.quora.com/Homework-Ques...-program-that-produces-the-following-output-1
Some of these responses are really great.
A lot of those answers seem... way more complicated than need be?
Rotate a sphere by dragging with the mouse. Have it not freak out when you go over a pole.What's a good simple program I can do that will help me apply what I'm learning in Linear Algebra? I don't know if doing some sort of 3D stuff would be simple enough because I've never done anything like that before, but maybe it is simpler than I'd expect. I guess I'm looking for an example where I could solve a certain problem using the stuff in Linear Algebra that maps to a context outside of Linear Algebra. Like, not just mapping one vector subspace to another through a linear transformation. But something that will allow me to use that skill to answer something useful.
I'm not entirely opposed to it, but that would require me to learn how to create 3D objects and have them interactable with a mouse. I've never done that. What is a good platform to do something like this?Rotate a sphere by dragging with the mouse. Have it not freak out when you go over a pole.
Unity would be trivialI'm not entirely opposed to it, but that would require me to learn how to create 3D objects and have them interactable with a mouse. I've never done that. What is a good platform to do something like this?
*snip*
Last week, I applied at company B. And B is simply amazing.
In terms of employee count, it's way bigger than A, but they nonetheless have some kind of startup vibe. Young, dynamic/agile, enthusiastic, skilled people full of bright ideas. Again, a very personal culture. Truckloads of perks. Many, many learning opportunities. Flexible work times. Many team events (barbecues, cinema, sports, ...).
In fact, in the last three years, they won a prestigious "Most Popular Employer [of the country]" award.
In terms of technology, they too are focused on Java, but they also use a lot of other extremely interesting stuff. I'd love to learn so much of it. Their set of preferred tools and technologies is seriously attractive. And their project portfolio is very diverse, too.
I want that job so badly. However, as you might expect, they're looking for seriously talented people. And I don't think I qualify. The company is also known for holding popular programming contests, and finishing one of their tests is part of the application process. They have a bunch of example tests of varying lengths and difficulties on their site. I tried some of them. They're really tricky.
*snip*
Oh yeah I just put that path in as an example. I got the exact path stored in a variable. However, I just tried shutil.rmtree and no dice. Still the same issue Process is being used by the software I'm launching the Python script from. I have to close the software to release thr Windows permission. I can actually individually delete the files contained within the destination folder though, but just not the folder itself. Really scratching my head on this haha.I'd rather use shutil.rmtree('test/B/') after being sure you're in the correct directory... Why an absolute path?
Especially on Windows where absolute path are not completely absolute if you omit the drive.
And be really, really, really careful, you work without safety net, you won't see "Are you sure you want to delete everything on the disk Y/N?"...
Sub populate()
Dim i As Integer
i = 2
Dim wrks As Worksheet
Set wrks = Sheets("result")
While IsEmpty(Sheets(wrks).Cells(i, 2)) <> True
Worksheets(wrks).Cells(i, 1).Value = "AAA"
Worksheets(wrks).Cells(i, 3).Value = "BB0"
Worksheets(wrks).Cells(i, 5).Value = "CC0"
Worksheets(wrks).Cells(i, 7).Value = "AD_MAN"
If Worksheets(wrks).Cells(i, 6).Value = "DDDD" Then
Worksheets(wrks).Cells(i, 4).Value = "TT.74"
Else
Worksheets("Tulemus").Cells(i, 4).Value = "TT.0"
End If
i = i + 1
Wend
End sub
Function datamine(i As Integer)
i = 1
While Worksheets("Data").Cells(2, i).String <> "Total Actual Cost"
i = i + 1
Wend
End function
That's what I expected, seeing the error you reported...Oh yeah I just put that path in as an example. I got the exact path stored in a variable. However, I just tried shutil.rmtree and no dice. Still the same issue
Hmmm ok if I were to just execute a .py file from the software instead, would that bypass the whole process thing? Like, in the software, I'll just have it execute a separate .py file instead of running the full script from within. That might work, right?That's what I expected, seeing the error you reported...
It seems that the software has a handle on the directory (you can check it with sysinternals process explorer, for example), and in this case, there's unfortunately no really safe things to do on the script side as far as I know. :/
If you can change the software itself, you can try to discard the handle on the directory when you don't need it anymore...
Alright. Today's the big day. The test will be unlocked in 40 minutes. I've got four hours to complete it.
Unfortunately, I'm 99% sure it won't. You really have to find the handle and release it. :/Hmmm ok if I were to just execute a .py file from the software instead, would that bypass the whole process thing? Like, in the software, I'll just have it execute a separate .py file instead of running the full script from within. That might work, right?
A picross solver? That's interesting... I'd be curious to hear about the details. Are they public?
Yeah I just tested it earlier and no dice. Oh well. I will just create a big pop up message box to tell the user that you cannot overwrite. Technically you're not supposed to anyways... Thanks for all your helpA picross solver? That's interesting... I'd be curious to hear about the details. Are they public?
Unfortunately, I'm 99% sure it won't. You really have to find the handle and release it. :/
you wouldn't use php to do this. You could probably fudge it but it's unclear why you'd ever do it that way.
Just finished it. The task was to develop a Picross solver, and it was split into seven stages. Unfortunately, I managed to complete only five of them. I made a few stupid mistakes which cost me some time, and the difficulty spike from stage 5 to 6 was huge. Ran out of time.
Finishing all seven stages is not required to be hired, though. It's just to get an idea of the skills of the applicant.
Hmm then perhaps I need to ask my instructor something, because we're supposed to be building webpages in PHP/HTML and not using javascript.
<div></div>
<form method="POST">
<button name="hidediv" value="true">Hide Div</button>
</form>
I wish they were non-convoluted and clever ways to do this in pure CSS. I'm still reluctant to use javascript, is only because as a user, I don't like to give so much leeway to webpages in term of processing (I still often have javascript disabled).it's an extremely antiquated way to do dynamic HTML before Javascript was common and is a bad user experience because it requires reloading the entire page from the server for a tiny change.
I wish they were non-convoluted and clever ways to do this in pure CSS. I'm still reluctant to use javascript, is only because as a user, I don't like to give so much leeway to webpages in term of processing (I still often have javascript disabled).