Search Results

Search found 464 results on 19 pages for 'segments'.

Page 1/19 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to load models in the extended MY_Router class in codeigniter

    - by askkirati
    I am not able to load models to the extended My_Router class in codeigniter. Below is my code: class MY_Router extends CI_Router { function MY_Router() { parent::CI_Router(); } function _validate_request($segments) { // Does the requested controller exist in the root folder? if (file_exists(APPPATH.'controllers/'.$segments[0].EXT)) { return $segments; } // Is the controller in a sub-folder? if (is_dir(APPPATH.'controllers/'.$segments[0])) { // Set the directory and remove it from the segment array $this->set_directory($segments[0]); $segments = array_slice($segments, 1); if (count($segments) > 0) { // Does the requested controller exist in the sub-folder? if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT)) { show_404($this->fetch_directory().$segments[0]); } } else { $this->set_class($this->default_controller); $this->set_method('index'); // Does the default controller exist in the sub-folder? if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT)) { $this->directory = ''; return array(); } } return $segments; } // Let's check if there are category segments $category_routes = $this->category_routing($segments); if($category_routes !== FALSE) { return $category_routes; } $user_routes = $this->user_routing($segments); if($user_routes != FALSE) { return $user_routes; } show_404($segments[0]); } function category_routing($segments) { $this->load->model('category_model'); if($this->category_model->category_exist($segments[0])) { //if only category if(count($segments)==1) { return array('category', 'category_browse', $segments[0]); } //category pagination if(count($segments)==2 and is_numeric($segments[1])) { return array('category','category_browse', $segments[0], $segments[1]); } //category upcoming if(count($segments)==2 and $segments[1] == 'upcoming') { return array('category','upcoming', $segments[0]); } //category upcoming pagination if(count($segments)==3 and $segments[1] == 'upcoming' and is_numeric($segments[3])) { return array('category','upcoming', $segments[0], $segments[3]); } //category top if(count($segments)==3 and $segments[1] == 'top') { return array('category','top', $segments[0], $segments[2]); } //category top pagination if(count($segments)==4 and $segments[1] == 'top' and is_numeric($segments[3])) { return array('category','top', $segments[0], $segments[3]); } } return FALSE; } function user_routing($segments) { $this->load->model('dx_auth/users', 'user_model'); if($this->user_model->check_username($segments[0])) { //only profile if(count($segments)==1) { return array('user','profile',$segments[0]); } //all friends if(count($segments)==2 and $segment[1]=='allfriends') { return array('user','allfriends',$segments[0]); } //all subscribers if(count($segments)==2 and $segment[1]=='allsubscribers') { return array('user','allsubscribers',$segments[0]); } //all subscription if(count($segments)==2 and $segment[1]=='allsubscriptions') { return array('user','allsubscriptions',$segments[0]); } } return FALSE; } } I have tried loading the models by using get_instance function provided by codeigniter but seems like it doesnot work. All i need is load the models in extended system library.

    Read the article

  • Reason for different segments in Linux on x86

    - by anjruu
    Hey all, So, I know that Linux uses four default segments for an x86 processor (kernel code, kernel data, user code, user data), but they all have the same base and limit (0x00000000 and 0xfffff), meaning each segment maps to the same set of linear addresses. Given this, why even have user/kernel segments? I understand why there should be separate segments for code and data (just due to how the x86 processor deals with the cs and ds registers), but why not have a single code segment and a single data segment? Memory protection is done through paging, and the user and kernel segments map to the same linear addresses anyway. Thanks! anjruu

    Read the article

  • visit counts in advanced segments not consistant

    - by user671201
    My organization has recently noticed an issue when applying advanced segments to visit counts during different time ranges. With no advanced segments turned on, here are the visit counts for Oct 1st - Oct 4th during the time range Sept 8th - Oct 8th: Oct 1 - 7 Oct 2 - 7 Oct 3 - 8 Oct 4 - 5 Again, with no advanced segments turned on, here are the visit counts for Oct 1st - Oct 4th but I've changed the time range to Oct 1st - Oct 4th. As expected, the numbers are the exact same as above: Oct 1 - 7 Oct 2 - 7 Oct 3 - 8 Oct 4 - 5 Now, I turn on the "Non paid search traffic" advanced segment. Here are the visit counts for Oct 1st - Oct 4th during the time range Sept 8th - Oct 8th: Oct 1 - 0 Oct 2 - 0 Oct 3 - 0 Oct 4 - 2 Here is where it gets weird. I keep the advanced segment on, and change the time range to Oct 1st - Oct 4th. This is what I get for the exact same dates as above: Oct 1 - 4 Oct 2 - 2 Oct 3 - 6 Oct 4 - 5 We've found the same inconsistency in our other GA profiles that get much more traffic (the above numbers come from one of our specialized topic blogs), but the inconsistency is less pronounced where there are more visits. My question is: why are the visit counts different for different time ranges when advanced segments are turned on, but exactly the same when no advanced segments are applied? Is this a GA bug or am I missing something about how the advanced segments work?

    Read the article

  • Le SaaS influence très peu de segments du marché des logiciels, d'après une étude de Forrester

    Le SaaS a peu ou presque pas d'impact sur un grand nombre de segments du marché des logiciels d'après un rapport de Forrester Le marché du SaaS (Software as a Service) depuis quelques années est en très forte croissance. La révolution du SaaS et l'orientation des éditeurs de logiciels vers celui-ci tendent à faire croire que les applications seront pratiquement tous proposées à un moment donné en mode SaaS. Cependant, un récent rapport de Forrester vient modérer cela. En effet, l'analyse de l'impact actuel et futur du SaaS sur 123 segments de marché du logiciel par le cabinet de recherche montre que les logiciels en mode SaaS auront peu d'impact ou même pas sur un grand nombre de ces segments...

    Read the article

  • BizTalk–Mapping repeating EDI segments using a Table Looping functoid

    - by Bill Osuch
    BizTalk’s HIPAA X12 schemas have several repeating date/time segments in them, where the XML winds up looking something like this: <DTM_StatementDate> <DTM01_DateTimeQualifier>232</DTM01_DateTimeQualifier> <DTM02_ClaimDate>20120301</DTM02_ClaimDate> </DTM_StatementDate> <DTM_StatementDate> <DTM01_DateTimeQualifier>233</DTM01_DateTimeQualifier> <DTM02_ClaimDate>20120302</DTM02_ClaimDate> </DTM_StatementDate> The corresponding EDI segments would look like this: DTM*232*20120301~ DTM*233*20120302~ The DateTimeQualifier element indicates whether it’s the start date or end date – 232 for start, 233 for end. So in this example (an X12 835) we’re saying the statement starts on 3/1/2012 and ends on 3/2/2012. When you’re mapping from some other data format, many times your start and end dates will be within the same node, like this: <StatementDates> <Begin>20120301</Begin> <End>20120302</End> </StatementDates> So how do you map from that and create two repeating segments in your destination map? You could connect both the <Begin> and <End> nodes to a looping functoid, and connect its output to <DTM_StatementDate>, then connect both <Begin> and <End> to <DTM_StatementDate> … this would give you two repeating segments, each with the correct date, but how to add the correct qualifier? The answer is the Table Looping Functoid! To test this, let’s create a simplified schema that just contains the date fields we’re mapping. First, create your input schema: And your output schema: Now create a map that uses these two schemas, and drag a Table Looping functoid onto it. The first input parameter configures the scope (or how many times the records will loop), so drag a link from the StatementDates node over to the functoid. Yes, StatementDates only appears once, so this would make it seem like it would only loop once, but you’ll see in just a minute. The second parameter in the functoid is the number of columns in the output table. We want to fill two fields, so just set this to 2. Now drag the Begin and End nodes over to the functoid. Finally, we want to add the constant values for DateTimeQualifier, so add a value of 232 and another of 233. When all your inputs are configured, it should look like this: Now we’ll configure the output table. Click on the Table Looping Grid, and configure it to look like this: Microsoft’s description of this functoid says “The Table Looping functoid repeats with the looping record it is connected to. Within each iteration, it loops once per row in the table looping grid, producing multiple output loops.” So here we will loop (# of <StatementDates> nodes) * (Rows in the table), or 2 times. Drag two Table Extractor functoids onto the map; these are what are going to pull the data we want out of the table. The first input to each of these will be the output of the TableLooping functoid, and the second input will be the row number to pull from. So the functoid connected to <DTM01_DateTimeQualifier> will look like this: Connect these two functoids to the two nodes we want to populate, and connect another output from the Table Looping functoid to the <DTM_StatementDate> record. You should have a map that looks something like this: Create some sample xml, use it as the TestMap Input Instance, and you should get a result like the XML at the top of this post. Technorati Tags: BizTalk, EDI, Mapping

    Read the article

  • plot of multiple line segments on 2D plot in Mathematica

    - by Bruce
    Hi, I would like to plot multiple, perhaps thousands of line segments on a single 2D plot in Mathematica. These line segments would be determined from an algorithm that would detected and save each segments endpoints. Once the algorithm has determined all the line segments within a finite 2D plot domain and range (e.g., x = 0,4 and y=0,0.5), I would like to plot them all on a single plot. Thanks for any suggestions.

    Read the article

  • convert multiple segments of DVD to FLV

    - by Josh
    I have a DVD of footage that I need to convert to FLV. I would rather not convert the whole disk as I only need specific segments. Is there a program that I can input start and end times and to get multiple files of these segments? Can you also advise on the best settings to use for best quality at the smallest file sizes. I'm working on a Vista 64bit machine. Thanks. Josh

    Read the article

  • nginx rewrite rule to convert URL segments to query string parameters

    - by Nick
    I'm setting up an nginx server for the first time, and having some trouble getting the rewrite rules right for nginx. The Apache rules we used were: See if it's a real file or directory, if so, serve it, then send all requests for / to Director.php DirectoryIndex Director.php If the URL has one segment, pass it as rt RewriteRule ^/([a-zA-Z0-9\-\_]+)/$ /Director.php?rt=$1 [L,QSA] If the URL has two segments, pass it as rt and action RewriteRule ^/([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/$ /Director.php?rt=$1&action=$2 [L,QSA] My nginx config file looks like: server { ... location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } How do I get the URL segments into Query String Parameters like in the Apache rules above? UPDATE 1 Trying Pothi's approach: # serve static files directly location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html)$ { access_log off; expires 30d; } location / { try_files $uri $uri/ /Director.php; rewrite "^/([a-zA-Z0-9\-\_]+)/$" "/Director.php?rt=$1" last; rewrite "^/([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/$" "/Director.php?rt=$1&action=$2" last; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } This produces the output No input file specified. on every request. I'm not clear on if the .php location gets triggered (and subsequently passed to php) when a rewrite in any block indicates a .php file or not. UPDATE 2 I'm still confused on how to setup these location blocks and pass the parameters. location /([a-zA-Z0-9\-\_]+)/ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME ${document_root}Director.php?rt=$1{$args}; include fastcgi_params; } UPDATE 3 It looks like the root directive was missing, which caused the No input file specified. message. Now that this is fixed, I get the index file as if the URL were / on every request regardless of the number of URL segments. It appears that my location regular expression is being ignored. My current config is: # This location is ignored: location /([a-zA-Z0-9\-\_]+)/ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index Director.php; set $args $query_string&rt=$1; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location / { try_files $uri $uri/ /Director.php; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index Director.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

    Read the article

  • Two parallel line segments intersection

    - by Judarkness
    I know there are many algorithms to verify whether two line segments are intersected. But once they encountered parallel condition, they just tell the user a big "No" and pretend there is no overlap, share end point, or end point collusion. I know I can can calculate the distance between 2 lines segments. If the distance is 0, check the end points located in the other line segments or not. And this means I have to use a lot of if else and && || conditions. This is not difficult, but my question is "Is there a trick( or mathematics) method to calculate this special parallel case?"

    Read the article

  • Detecting coincident subset of two coincident line segments

    - by Jared Updike
    This question is related to: How do I determine the intersection point of two lines in GDI+? (great explanation of algebra but no code) How do you detect where two line segments intersect? (accepted answer doesn't actually work) But note that an interesting sub-problem is completely glossed over in most solutions which just return null for the coincident case even though there are three sub-cases: coincident but do not overlap touching just points and coincident overlap/coincident line sub-segment For example we could design a C# function like this: public static PointF[] Intersection(PointF a1, PointF a2, PointF b1, PointF b2) where (a1,a2) is one line segment and (b1,b2) is another. This function would need to cover all the weird cases that most implementations or explanations gloss over. In order to account for the weirdness of coincident lines, the function could return an array of PointF's: zero result points (or null) if the lines are parallel or do not intersect (infinite lines intersect but line segments are disjoint, or lines are parallel) one result point (containing the intersection location) if they do intersect or if they are coincident at one point two result points (for the overlapping part of the line segments) if the two lines are coincident

    Read the article

  • PHP pass associative array from one function to another wihle keeping keys intact

    - by veronica
    I have two functions and one array function A { $segments = array(); $segments['word']=$var1; $segments['word2']=$var2; $segments['word3']=$var3; return $segments; } function B { $someVar=$segments['word']; $someVar1=$segments['word']; $someVar2=$segments['word']; $vars['other_stuff']... return $vars; } but I am not passing $segments['word']...word3'] to the second function. I am passing $segments[0]; $segments[1]; etc... How can I pass the keys to second function $segments['word'] $segments['word1'] $segments['word2'] Thank you,

    Read the article

  • Extract segments from FLV file?

    - by overtherainbow
    Hello I'm no expert with editing videos, and I need to rip a few segments from an FLV file, and then upload some of them to YouTube. I don't know if I need to convert FLV to AVI for YouTube to accept them. I've taken a look at VirtualDub + the FLV plug-in but the video isn't displayed correctly. I also tried AviDemux, but I couldn't find how to extract a segment after setting the A/Start and B/End points. Does someone know of a good solution to do this on Windows? Thank you.

    Read the article

  • How to load chunks of 2d map segments when player reaches a certain point?

    - by 2kan
    In my 2d platformer (made with Java and Slick2d), random maps are made by combining different segments together and displaying them one after the other. My problem is that I can't load too many segments or the game will run out of memory, so I want to load n number of segments at a time in chunks, then load the next chunk when the player comes near the end of one. I've attempted to do this for a couple of hours now, but I just can't get it to work at all. This is my chunk generation function where chunkLoad is the number of segments to load and BLOCK_WIDTH is the number of blocks/tiles each segment is across. Chunk1 and map are arrays of segments. Random r = new Random(); for(int i=0; i<chunkLoad; i++) { int id = r.nextInt(4)+2; chunk1[i] = new BlockMap("res/window/map"+id+".tmx", i*BLOCK_WIDTH); } map = chunk1; chunksLoaded++; The map is then drawn on the screen like this. tmap is a TiledMap object and each block/tile is 16 pixels wide for(int i=0; i<chunkLoad; i++) { map[i].tmap.render((i * BLOCK_WIDTH * 16) + (cameraX), 0); } I can successfully load new chunks, but I can't display them in the correct position, nor the hitboxes. Any suggestions? Thanks.

    Read the article

  • Separating date ranges into separate segments in SQL

    - by Richard
    I have a table containing 2 date fields and an identifier (id, fromdate and todate) These dates overlap in any and every possible way. I need to produce a list of segments each with a start and end date describing the separate segments in that list. For example: id, FromDate ToDate 1, 1944-12-11, 1944-12-31 2, 1945-01-01, 1945-12-31 3, 1945-01-01, 1945-06-30 4, 1945-12-31, 1946-05-01 5, 1944-12-17, 1946-03-30 Should produce all the segments of all the overlaps: 1, 1944-12-11, 1944-12-16 1, 1944-12-17, 1944-12-31 5, 1944-12-17, 1944-12-31 2, 1945-01-01, 1945-06-30 3, 1945-01-01, 1945-06-30 5, 1945-01-01, 1945-06-30 2, 1945-07-01, 1945-12-09 5, 1945-07-01, 1945-12-09 2, 1945-12-10, 1945-12-31 4, 1945-12-10, 1945-12-31 5, 1945-12-10, 1945-12-31 4, 1946-01-01, 1946-03-30 5, 1946-01-01, 1946-03-30 4, 1946-04-01, 1946-05-01 Or perhaps a diagram might help INPUT 1 <----> 2 <-----------> 3 <-----> 4 <----------> 5 <-----------------> OUTPUT 1 <-> 1 <-> 5 <-> 2 <-----> 3 <-----> 5 <-----> 2 <-> 5 <-> 2 <-> 4 <-> 5 <-> 4 <-> 5 <-> 4 <----> Please help

    Read the article

  • Generate links for routes with non-parameter url segments on ASP.NET MVC 2

    - by spapaseit
    I have a route defined with several hardcoded (non-parameter) segments: routes.MapRoute(null, "suggestion/list/by/{tag}", new { controller = "Suggestion", action = "List", tag = UrlParameter.Optional }); Suppose I'm in the Index view of SuggestionController, which has a Suggestion object for Model, how can I create a link that matches that route? I'd rather use one of the provided helpers and keep the route name as null in order to avoid hard-coding to much on my views, but I can't figure out how to user these non-parameter segments in Html.ActionLink or RouteLink methods. I've even tried to render the link using plain ol' html <a href="/suggestion/list/by/<%=Model.Tag %>"><%=Model.Tag %></a> but this somehow didn't match the route either. There's probably a very simple solution and I might be over-complicating things in mi mind, but I'm at a loss. Any ideas? Thanks in advance.

    Read the article

  • calculate intersection between two segments in a symmetric way

    - by Elazar Leibovich
    When using the usual formulas to calculate intersection between two 2D segments, ie here, if you round the result to an integer, you get non-symmetric results. That is, sometimes, due to rounding errors, I get that intersection(A,B)!=intersection(B,A). The best solution is to keep working with floats, and compare the results up to a certain precision. However, I must round the results to integers after calculating the intersection, I cannot keep working with floats. My best solution so far was to use some full order on the segments in the plane, and have intersection to always compare the smaller segment to the larger segment. Is there a better method? Am I missing something?

    Read the article

  • Shortest distance between two line segments

    - by Frank
    I need a function to find the shortest distance between two line segments. A line segment is defined by two endpoints. So for example one of my line segments (AB) would be defined by the two points A (x1,y1) and B (x2,y2) and the other (CD) would be defined by the two points C (x1,y1) and D (x2,y2). Feel free to write the solution in any language you want and I can translate it into javascript. Please keep in mind my geometry skills are pretty rusty. I have already seen http://stochastix.wordpress.com/2008/12/28/distance-between-two-lines/ and I am not sure how to translate this into a function. Thank you so much for help.

    Read the article

  • What segments does C compiled program use?

    - by b-gen-jack-o-neill
    Hi, I read on OSDev wiki, that protected mode of x86 architecture allow you to create separate segments for code and data, while you cannot write into code section. That Windows (yes, this is the platform) loads new code into code segment, and data are created on data segment. But, if this is the case, how does program know it must switch segments to the data segment? Becouse if I understand it right, all adress instructions point to the segment you run the code from, unless you switch the descriptor. But I also read, that so colled flat memory model allows you to run code and data within one segment. But I read this only in connection to assembler. So, please, what is the case with C compiled code on Windows? Thanks.

    Read the article

  • Regular expression match, extracting only wanted segments of string

    - by Ben Carey
    I am trying to extract three segments from a string. As I am not particularly good with regular expressions, I think what I have done could probably be done better... I would like to extract the bold parts of the following string: SOMETEXT: ANYTHING_HERE (Old=ANYTHING_HERE, New=ANYTHING_HERE) Some examples could be: ABC: Some_Field (Old=,New=123) ABC: Some_Field (Old=ABCde,New=1234) ABC: Some_Field (Old=Hello World,New=Bye Bye World) So the above would return the following matches: $matches[0] = 'Some_Field'; $matches[1] = ''; $matches[2] = '123'; So far I have the following code: preg_match_all('/^([a-z]*\:(\s?)+)(.+)(\s?)+\(old=(.+)\,(\s?)+new=(.+)\)/i',$string,$matches); The issue with the above is that it returns a match for each separate segment of the string. I do not know how to ensure the string is the correct format using a regular expression without catching and storing the match if that makes sense? So, my question, if not already clear, how I can retrieve just the segments that I want from the above string?

    Read the article

  • Maximum number of memory segments that Notes can support has been exceeded

    - by Sagy
    hi All, I am using Domino.dll to access a NSF file in C#.NET 2.0 I am using multiple thread to access 4 NSF files at a time, its working fine for small NSF files, but if i try to access large NSF files i get the Out of Memory Exception and Maximum number of memory segments that Notes can support has been exceeded. This exception usually occurs when i access NotesDocument object from a large NSFVIewFolder in a while loop. I am releasing the instance of the NotesDocument by using the Marshal.ReleaseComObject(NotesDocument); still it throws the same exception. My goal is to access multiple NSF files at a time (MAX 4 NSF files at a time) for large NSF files (may be in GB). Kindly help me, if you got some solution. Thanks.

    Read the article

  • Listing all shared memory segments used by a process on AIX5.3+

    - by Frank Meerkötter
    I would like to find all shared memory segments used by a given process. I am especially interested in figuring out the shmid so i can use it in calls to shmctl(). On Solaris i would just read /proc/$PID/map to figure out that information (field pr_shmid). The contents of that file are defined by struct prmap_t in sys/procfs. AIX also has a /proc/$PID/map file. There is also a struct prmap but unfortunately it is missing the pr_shmid field. Any ideas how i can achieve this on AIX5.3+?

    Read the article

  • 301 Redirect adding incorrect extra segments to a url

    - by Pentland_web
    I need to 301 redirect one segment of a url to a new version of it. My aim is redirect www.domain.co.uk/farm/whatever/ to www.domain.co.uk/farm_cottages/whatever/ The rule I am using to do this is: RedirectMatch 301 ^/farm/ /farm_cottages/ However for some reason it partially works but appends ?/farm/ after farm_cottages/ in the final url ie. www.domain.co.uk/farm_cottages/?/farm/whatever/ Here is my entire rewrite rule set as I believe one of the rewrite rules could be interfering with the redirect rule. #redirect /farm/ to /farm_cottages/ RedirectMatch 301 ^/farm/ /farm_cottages/ <IfModule mod_rewrite.c> RewriteEngine on # no WWW to WWW RewriteCond %{HTTP_HOST} !^www.domain.co.uk$ [NC] RewriteRule ^(.*)$ http://www.domain.co.uk/$1 [R=301,L] # Force trailing slash on URLs RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://www.domain.co.uk/$1/ [L,R=301] #Remove index.php RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC] RewriteRule ^index\.php(.+) $1 [R=301,L] </IfModule> The site is built in Expressionengine and so the segments of url do not represent actual folders - I don't think this should matter though. Any ideas would be much appreciated! Thanks

    Read the article

  • segmented reduction with scattered segments

    - by Christian Rau
    I got to solve a pretty standard problem on the GPU, but I'm quite new to practical GPGPU, so I'm looking for ideas to approach this problem. I have many points in 3-space which are assigned to a very small number of groups (each point belongs to one group), specifically 15 in this case (doesn't ever change). Now I want to compute the mean and covariance matrix of all the groups. So on the CPU it's roughly the same as: for each point p { mean[p.group] += p.pos; covariance[p.group] += p.pos * p.pos; ++count[p.group]; } for each group g { mean[g] /= count[g]; covariance[g] = covariance[g]/count[g] - mean[g]*mean[g]; } Since the number of groups is extremely small, the last step can be done on the CPU (I need those values on the CPU, anyway). The first step is actually just a segmented reduction, but with the segments scattered around. So the first idea I came up with, was to first sort the points by their groups. I thought about a simple bucket sort using atomic_inc to compute bucket sizes and per-point relocation indices (got a better idea for sorting?, atomics may not be the best idea). After that they're sorted by groups and I could possibly come up with an adaption of the segmented scan algorithms presented here. But in this special case, I got a very large amount of data per point (9-10 floats, maybe even doubles if the need arises), so the standard algorithms using a shared memory element per thread and a thread per point might make problems regarding per-multiprocessor resources as shared memory or registers (Ok, much more on compute capability 1.x than 2.x, but still). Due to the very small and constant number of groups I thought there might be better approaches. Maybe there are already existing ideas suited for these specific properties of such a standard problem. Or maybe my general approach isn't that bad and you got ideas for improving the individual steps, like a good sorting algorithm suited for a very small number of keys or some segmented reduction algorithm minimizing shared memory/register usage. I'm looking for general approaches and don't want to use external libraries. FWIW I'm using OpenCL, but it shouldn't really matter as the general concepts of GPU computing don't really differ over the major frameworks.

    Read the article

  • Code Golf: Seven Segments

    - by LiraNuna
    The challenge The shortest code by character count to generate seven segment display representation of a given hex number. Input Input is made out of digits [0-9] and hex characters in both lower and upper case [a-fA-F] only. There is no need to handle special cases. Output Output will be the seven segment representation of the input, using those ASCII faces: _ _ _ _ _ _ _ _ _ _ _ _ | | | _| _| |_| |_ |_ | |_| |_| |_| |_ | _| |_ |_ |_| | |_ _| | _| |_| | |_| _| | | |_| |_ |_| |_ | Restrictions The use of the following is forbidden: eval, exec, system, figlet, toilet and external libraries. Test cases: Input: deadbeef Output: _ _ _ _ _ _||_ |_| _||_ |_ |_ |_ |_||_ | ||_||_||_ |_ | Input: 4F790D59 Output: _ _ _ _ _ _ |_||_ ||_|| | _||_ |_| || | _||_||_| _| _| Code count includes input/output (i.e full program).

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >