Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Programming

Journal Journal: Boost UBLAS matrix iterators and templates - Solved

UPDATE: I had a look around, figured I would try substituting a std::vector<std::vector<double> > for the uBLAS matrix<double>, still got the same error. So I started looking better into templates (no, I'm not quite done with vol2 of "Thinking in C++") and found out about typename. Seems to fix the problem.

I know I should probably post this to stackoverflow or the Boost/UBLAS mailing list, but I figure there are plenty of smart people here at slashdot.

Let's say you are using UBLAS from Boost and you want to implement a cumulative summing function for matrices. Here's what I think is a fairly straightforward way to do it:

// For boost::numeric::ublas::matrix<>.
#include <boost/numeric/ublas/matrix.hpp>

// For std::partial_sum().
#include <numeric>

template<class T>
boost::numeric::ublas::matrix<T> cumSum
(const boost::numeric::ublas::matrix<T>& input_,
const bool& colWise_ = true)
{
using namespace boost::numeric::ublas;
using namespace std;

matrix<T> result_(input_);

if (colWise_)
for (matrix<T>::iterator2 colIter = result_.begin2();
colIter < result_.end2();
colIter++)
partial_sum(colIter.begin(),
colIter.end(),
colIter.begin());
else
for (matrix<T>::iterator1 rowIter = result_.begin1();
rowIter < result_.end1();
rowIter++)
partial_sum(rowIter.begin(),
rowIter.end(),
rowIter.begin());

return result_;
}

For now, I'm ignoring completely templatizing this to make the row-wise/column-wise distinction disappear in the code and focusing on just getting it working. Only it doesn't work; won't compile. Couldn't figure out why, but g++ kept saying it was expecting a ';' before colIter and rowIter. I had a hunch and replaced one of the iterator's 'T's with 'double' and it stopped complaining about that one. Am I missing something, or does UBLAS not implement iterators properly?What am I missing?

United States

Journal Journal: Koster/Larsen Debate 2

Many people, including myself, were disappointed that the Koster campaign chose to not participate in the KCTS 9 debate last Thursday.* But the next day, the pair debated and TVW has the video online.

If most voters watch this debate it's hard to see how Larsen could be re-elected, for one simple reason: everything Larsen said was about increasing the size, scope, power, and influence of the federal government. For every problem, Larsen sees the federal government as the solution. Even when Larsen correctly identifies mistakes Bush and the Republicans made in the last decade, Larsen indicts himself and his fellow Democrats because they want to do the same things the Republicans did, except more and bigger. Koster wants to go in the other direction: forward to liberty and smaller government instead of the monster debt that the Democrats and Republicans gave us last decade.

* I personally disagree with the Koster campaign decision to not participate on Thursday. Their stated reason was that Herald reporter and columnist Jerry Cornfield was one of the panelists, and the Koster campaign deemed him unacceptable because he's on the left, and they didn't believe he'd be fair. My take is that Koster could have handled Cornfield just fine, and that there's far less-fair journalists out there that Koster will run into if he's elected, and that he should have done the debate ... especially since, as this debate shows, the more Koster can put himself out there, side-by-side to Larsen, the better he looks: and that's something no journalist can take away, no matter how unfair they are.

Cross-posted on <pudge/*>.

United States

Journal Journal: Larsen and Koster on KCTS 9 9

Last night KCTS 9 had nice profiles on both John Koster (R) and Rick Larsen (D-inc.), the candidates for Washington's Second Congressional District (whom we collectively interviewed recently here on Sound Politics). The KCTS piece uncritically showed Larsen's dishonest ad falsely accusing Koster of wanting to privatize social security, and referred to an "anti-incumbent" wave that is generally understood to be anti-establishment, not anti-incumbent, but otherwise it was a pretty good piece.

The discussion afterward, however, was fairly awful. All of the pundits -- including former state GOP chair Chris Vance -- said the only thing Koster has going for him is the "wave" in favor of Republican candidates. Joni Balter said Koster is "rigid" and "inflexible," while Larsen has "been there" for his constituents (as if Koster hasn't been). Perhaps she missed the memo that most voters in the Second CD want government to "be there" for us by being a lot less "flexible" on government spending.

Next Thursday, October 21, at 7 p.m., KCTS 9 will host a debate between Larsen and Koster. Tune in!

Also check out this non-endorsement endorsement of Koster by the Seattle Times. They call Larsen out for his dishonesty, his lack of fiscal responsibility, and his desire to increase taxes. They praise Koster for his fiscal prudence, his experience, his responsible record, and says he would benefit Congress. But they say they don't endorse him because he agrees too much with his own constituents: he is anti-abortion, anti-gay marriage, and is (as every scientist and responsible politician is required by the rules of logic to be) skeptical of anthropogenic global warming.*

The Seattle Times says they endorse Larsen, but at the same time, they demonstrate that Koster would better represent his constituents. Draw your own conclusions.

* If you're a liberal, you're supposed to be skeptical of religion, skeptical of politicians, skeptical of authority and media of every kind, but not skeptical of anthropogenic global warming. Even the IPCC leaves open the door that AGW may not be true; how could any lay person think there's no room for that? To decry skepticism in the face of uncertainty is to be anti-intellectual, and it is incumbent upon every policymaker and scientist to remain open-minded on all such issues.

Cross-posted on <pudge/*>.

User Journal

Journal Journal: What a socialist is 9

Anyone who defines what a socialist IS and states that therefore someone is NOT a socialist doesn't understand the word "socialist" or the English language very well.

The fact is, "socialist" has many meanings. In both French and English, for around 150 years, "socialist" has had a definition -- which has been very commonly used, even to today -- of, simply, massive social control by government for the purpose of taking from some people to give to others. As Bastiat said, for example:

Now, legal plunder can be committed in an infinite number of ways. Thus we have an infinite number of plans for organizing it: tariffs, protection, benefits, subsidies, encouragements, progressive taxation, public schools, guaranteed jobs, guaranteed profits, minimum wages, a right to relief, a right to the tools of labor, free credit, and so on, and so on. All these plans as a whole -- with their common aim of legal plunder -- constitute socialism.

Socialism does not just regard the ownership of the means of production. It's never only meant that, not in our lifetimes. Obama does favor controlling society through "an infinite number of ways" in order to take from some people to give to others. This is a perfectly reasonable, correct, and valid use of the word "socialism" ... and it's not a matter of "human dignity," but a matter of whether government should be the instrument of providing that "dignity." I contend that destroying liberty to give "dignity" to someone else is itself taking away the dignity of all.

Or, in other words of Bastiat:

Mr. de Lamartine once wrote to me thusly: "Your doctrine is only the half of my program. You have stopped at liberty; I go on to fraternity." I answered him: "The second half of your program will destroy the first."

United States

Journal Journal: Murray Pretends There Is No Deficit

Several times in tonight's debate, Senator Patty Murray said that keeping taxes at their current level would make it impossible to fund critical federal programs. But the Democratic Congress, with Murray's votes, has shown no restraint in spending caused by a lack of revenue, racking up deficits of trillions of dollars.

On what planet does anyone believe that the Murray, or the Democratic Congress, is restrained by a lack of revenue?

Cross-posted on <pudge/*>.

Bug

Journal Journal: Slashdot link weirdness solved: rogue link tracker 5

In the last week or two links to external sites on Slashdot generally don't seem to work unless I click several times. This only appears to happen on Firefox... Chrome is unaffected. I haven't tried IE, Safari, or any other browser. Finally fed up with it, I decided to look through the javascript to see if there was anything funky going on. Looks like there's a script being included from leads.demandbase.com that defines some kind of click tracker. Here's a snippet:

  • else if(a[i].className.match(/clicky_log_outbound/i)){clicky.add_event(a[i],"mousedown",clicky.outbound);}else{clicky.add_event(a[i],"mousedown",clicky.click);

So if you find you've oddly had to click a few times to RTFA, it's not your mouse button dying. Open up adblock and disable everything from leads.demandbase.com and it will be fixed. Links clicked once in Firefox will properly load as they used to. Thanks Slashdot for using an external company for tracking my click behavior. Though perhaps implementing this poorly is Taco's way of giving us a heads-up. Much like the "Idle" section, his overlords may have mandated the addition of this awesomeness to the site and by making it break it alerts us to what we need to block. In which case, a non-sarcastic thanks is due.

I also found this wonderful gem:

  • function pageload_done( $, console, maybe ){
            pageload.after_readycode = (new Date).getTime();
            pageload.content_ready_time = pageload.content_ready - pageload.before_content;
            pageload.script_ready_time = pageload.after_readycode - pageload.content_ready;
            pageload.ready_time = pageload.after_readycode - pageload.before_content; // Only report 1% of cases.
            maybe || (Math.random()>0.01) || $.ajax({ data: {
                    op: 'page_profile',
                    pagemark: pageload.pagemark,
                    dom: pageload.content_ready_time,
                    js: pageload.script_ready_time
            } });
    }

Unless my javascript is really rusty, won't this report 99% of cases?

Anyway, pass this information on so everyone can RTFA without the hassle.

United States

Journal Journal: State Liquor Status Quo "Economically ... Doesn't Make Sense" 1

Am I the only one who noticed that in Robert Mak's piece on the liquor privatization initiatives on KING 5, a supporter of the status quo said that the status quo doesn't make economic sense?

John Guadnola, Executive Director of the Washington Beer and Wine Wholesalers Association -- which opposes both I-1100 and I-1105 -- said that if I-1100 passes, "[Safeway] won't have nearly the variety [as it has now] because economically, it just doesn't make sense for them."

But if it doesn't make economic sense for Safeway to have that variety, then why do we do it? If carrying a certain number of bottles in a local Safeway doesn't make economic sense, scaling up as we do now can't fix that problem. So Guadnola is basically admitting that -- in a time of severe recession, no less -- he and his group are backing a system that wastes money.

Of course, the truth is that wide variety will continue to exist. I've lived in several other states, all of which allowed retailers to buy with volume discounts and decide what they wanted to carry, and all of which had a wide variety of liquor widely available. We have one of the only states with this sort of a system, and all you have to do is look at the other states and see that almost every criticism of I-1100 is based on fantasy. The only true criticisms I've seen of I-1100 are that it would give us more access to the products we want to buy, which is, as best I can figure, a good thing.

(Oh, and I should also mention that the criticism that this takes money from schools is necessarily false. Any revenues lost by the schools -- if required to make "ample provision" for education -- must be made up by taking it from other programs, or increasing other taxes. Our Constitution requires it. For I-1100 to significantly hurt schools, our state government would have to violate the Constitution.)

Another truth is that the people most ardently defending the status quo, as well as the people behind I-1105, are no less influenced by their bottom lines than the backers of I-1100 ... and probably moreso. There are many people -- like me -- who don't consume liquor or are not in the liquor business, but value the freedom I-1100 provides.

But all of the people I've seen backing I-1105 or the status quo are in businesses that do, or would, profit from the government protection of their business interests, such as Guadnola's organization, whose members control about 95 percent of all beer and wine distribution in the state ... a virtual monopoly that is jeopardized by privatization. Of course, I have no problem with any of the companies represented by the WBWWA. They are probably all fine businesses doing fine work. I do have a problem with government being used to protect their interests, at the expense of the other interests of other companies and individuals.

My two cents? Vote Yes on I-1100, and No on I-1105 and other forms of government control.

Cross-posted on <pudge/*>.

United States

Journal Journal: Candy Tax

In order to avoid the new Candy Tax in Washington State, I am carefully selecting what candies to buy for Halloween. Candy is legally defined as not having any flour, so I am buying up Twix, Kit Kat, Twizzlers, and -- my favorite of all -- Nestle Crunch. Mmmmmm.

The funny thing is that I've found that flour products actually make me gain weight more than products more heavily based on sugar. I don't think Michelle Obama would approve of Christine Gregoire encouraging me to gain weight. And certainly, no one sane would approve of the government encouragement to punish the makers of certain candies over others just because it lists "flour" on the ingredients. But I must comply! Christine knows best!

Do your part by helping me and Christine punish the makers of candy without flour: make your Halloween a no-flour-free zone!

Cross-posted on <pudge/*>.

User Journal

Journal Journal: More reflections on geek relationships

This post got a lot of points and apparently a lot of traffic interest. An A.C. suggested that it was the first post they'd ever seen that should have been modded "+100", and _their_ post got modded up.

So now that I've gotten lots of people to read and think about what I wrote, and many who liked it, I'm going to diagree with part of it.

I think I was perhaps being too hard on AMD lady, and perhaps I was missing the focus of what she was talking about. My post deals a lot with _maintaining_ relationships and building them. But I think TFA was referring to _meeting_ geeks.. "catching" them if you will. And my post is potentially not relevant as a response to TFA.

There are some key points that I think still stand, but one thing that I want to revise or comment on a bit is when a woman takes an interest. The 1-liners or plausible topics of conversation postulated by the AMD lady didn't hit me because I am not that interested in PC video cards any more. So in the context of an advice blog to women about how to approach some easily-fits-in-a-box hypothetical geek, I rejected not only the premise but the specific lines used.

But then I got to thinking about my own history, and I remember a specifc time where I was at wedding reception or "couples baby shower" or some similar thing, and there was another woman there who had a real interest in cars and spirited driving. And so we chatted just breifly about it...I think she had heard that I was a car guy and so she approached me to talk about it.

Later that night I had to admit to my wife that it was troubling me just how _haunted_ I was with thoughts of this gal, because she approached me about an interest of mine, essentially out of nowhere, and it is an interest that women typically don't share -- certainly my wife doesn't. And so even though I was happily married, my thoughts that day kept returning to this woman. It was a few minutes of conversation and it was at least 8 years ago. Yet i still remember the experience and how i felt about it.

So there is certainly something to the idea of "snaring" a guy by letting him know you share his interests. I think the parts of my post that suggest you need to be authentic, legitimately interested, and so on all still apply. But I wouldn't want someone to read what I had written and come away with the idea that approaching a guy about his interests would be detrimental.

(As an aside, a great friend of mine, who is also a go-fast junkie, ended up having a very serious relationship with a younger girl who was _also_ a driver. And it turned ugly. Sometimes, shared passions/interests/hobbies make better introductions than they do compatible mates. I bet there is some interesting literature on competitiveness/etc dynamics within relationships where each party has some similar jobs/hobbies/interests/whatever).

User Journal

Journal Journal: "I could care less"

It's amazing how people try to rationalize away the phrase "I could care less", much in the same way that Star Wars apologists try to rationalize the use of parsecs when talking about the Kessel Run. Maybe there are black holes to navigate around, and minimizing the distance is the sign of a good pilot, or maybe this, or maybe that... or maybe George Lucas just made a mistake, you know?

So when it comes to people rationalizing away "I could care less" as being some nonchalant way of saying "yeah, I could but I'm not going to bother" I just don't buy it. It's a misquote of the perfectly unambiguous phrase "I couldn't care less". So when I stumbled across a rationalization of that, my mind wandered upon what I think is a pretty damned good analogy of why it doesn't make sense: I could eat more.

United States

Journal Journal: Koster vs. Larsen: Your Turn 3

The two campaigns for Washington's Second Congressional District, for incumbent Rick Larsen (D) and challenger John Koster (R), have agreed to answer questions posted by you, the readers and voters. This is going to be a close race, and perhaps one of the most-watched in the nation.

So here's how this works: you guys ask the questions, posting them in this Sound Politics discussion. I pick good ones and submit them to the candidates. They send their answers back to me, and I post them. I don't censor, edit, or modify their answers in any way (though as "interviewer," I may ask for clarifications, giving them a chance to revise their answers).

It's no secret that I want John Koster to win this election. But I'll do my best to pick good questions, and since everyone can see all the questions being asked by the commenters, everyone can decide for themselves if I did a reasonable job.

I'll close the questioning at the end of this week. Everyone -- from libertarian to liberal -- is welcome to submit questions here, but not to engage in discussions about the questions or candidates, or to be abusive. Ask questions: don't answer them or fight about them.

Have at it.

Cross-posted on <pudge/*>.

United States

Journal Journal: Koster Winning, Berkey Losing

There are some surprising twists in our interminable Washington election.

Republican John Koster has come from behind to take the lead in the Second Congressional District race by 160 votes, and is likely to end up beating incumbent Rick Larsen. The good news for Larsen is that the total Democrat vote is over 50 percent; the good news for Koster is that independents who didn't vote in the primary will likely swing his way in the general.

Of course, Koster won the primary in 2000, too: but Larsen ended up winning the general. But it was an open seat in 2000, and that the incumbent might finish second in the primary is really bad for Larsen.

Similarly, incumbent Democratic Senator Jean Berkey (38th LD) is coming in third in her primary, and is likely to be eliminated from the general election ballot. At 32.24% of the vote, she's falling behing Conservative candidate Rod Rieger at 32.63%, and fellow Democratic candidate Nick Harper at 35.13%.

According to Jerry Cornfield at The Herald, she'd be the only incumbent for the state legislature to fail to get to the general election this year. More incumbents, like Sound Politics troll Geoff Simpson, are likely to lose in the general, though.

Cross-posted on <pudge/*>.

United States

Journal Journal: Best Email of the Day

From the Democratic Party: "The only thing Boehner seems serious about is raising campaign cash. After the speech, he told reporters that he's prepared to help Republicans spend $50 million to win back Congress. ... Democrats have a different plan. We're asking supporters like you to make a contribution to the By the People Fund."

How dare Boehner say he's trying to raise money! We're different: we want to raise money!

Cross-posted on <pudge/*>.

User Journal

Journal Journal: Tragic Love Story Junkies anonymous 4

Hi, my name is Nat^H^H^HJim, and I admit, I have a problem: I'm addicted to tragic love stories.

It started simply enough with "Romeo and Juliet", but then I saw "Crouching Tiger, Hidden Dragon", and I was hooked, because it had not one, but TWO sets of star-crossed lovers.

Next was "Moulin Rouge", which even my gay brother despises. But it holds a special place in my heart.

I was okay for a while, high on such movies as "Fight Club". But then that bastard Chris Nolan had to make "Memento" (I'm particularly drawn to stories about men who have lost the woman they love). For some odd reason, the "Star Wars" prequels didn't really strike a chord, although they were close.

Then I got married, and I thought I was doing better. Then along comes "Inception". Oh sure, everyone hypes it for being "mind-bending" (what? it wasn't like it was "Primer"), but I secretly believe that Nolan knows how to make an excellent tragic love story, and it shows in not only "Memento" but "Inception".

As I sit here listening to the final track of the "Inception" soundtrack CD (the music from baggage claim to the credits; my favorite by far), I find myself hungry for more. I'm not even sure how to find more, as it's hard to describe. Some other stories I'm acquainted with touch close on similar feelings: the ending to "Lord of Light" by Zelazney, "Permutation City" by Egan (and even further off track, but still close in tone "Diaspora"). "The Fountain" by Aronofsky is definitely another movie that meets the criterion, as well as "Chasing Amy" by Kevin Smith.

I guess I could at least take a stab at some adjectives: a sense of loss, a longing for those truly special people we will never meet again, a feeling of mystery and awe; stories that end with catharsis. So, could you do a junkie a favor and find him one more fix? Thanks :)

Slashdot Top Deals

If all else fails, lower your standards.

Working...