Search Results

Search found 1544 results on 62 pages for 'weight'.

Page 9/62 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • cuda 5.0 namespaces for contant memory variable usage

    - by Psypher
    In my program I want to use a structure containing constant variables and keep it on device all long as the program executes to completion. I have several header files containing the declaration of 'global' functions and their respective '.cu' files for their definitions. I kept this scheme because it helps me contain similar code in one place. e.g. all the 'device' functions required to complete 'KERNEL_1' are separated from those 'device' functions required to complete 'KERNEL_2' along with kernels definitions. I had no problems with this scheme during compilation and linking. Until I encountered constant variables. I want to use the same constant variable through all kernels and device functions but it doesn't seem to work. ########################################################################## CODE EXAMPLE ########################################################################### filename: 'common.h' -------------------------------------------------------------------------- typedef struct { double height; double weight; int age; } __CONSTANTS; __constant__ __CONSTANTS d_const; --------------------------------------------------------------------------- filename: main.cu --------------------------------------------------------------------------- #include "common.h" #include "gpukernels.h" int main(int argc, char **argv) { __CONSTANTS T; T.height = 1.79; T.weight = 73.2; T.age = 26; cudaMemcpyToSymbol(d_consts, &T, sizeof(__CONSTANTS)); test_kernel <<< 1, 16 >>>(); cudaDeviceSynchronize(); } --------------------------------------------------------------------------- filename: gpukernels.h --------------------------------------------------------------------------- __global__ void test_kernel(); --------------------------------------------------------------------------- filename: gpukernels.cu --------------------------------------------------------------------------- #include <stdio.h> #include "gpukernels.h" #include "common.h" __global__ void test_kernel() { printf("Id: %d, height: %f, weight: %f\n", threadIdx.x, d_const.height, d_const.weight); } When I execute this code, the kernel executes, displays the thread ids, but the constant values are displayed as zeros. How can I fix this?

    Read the article

  • Would like some modelling tips for dependent values

    - by orjan
    I'm working on a model for a simple fishing competition and I have some issues with my design. The main class for the fishing game is Capture and it looks like this: public class Capture : Entity { public virtual int Weight { get; set; } public virtual int Length { get; set; } public virtual DateTime DateForCapture { get; set; } public virtual User CapturedBy { get; set; } public virtual Species Species { get; set; } } So far there´s no problem but I'm not really sure how to model the game. Every Species is connected to a reference weight that changes from year to year The number of point for a capture is its Weight divided by the current reference weight for the species. One way to solve the problem is to connect a capture to SpeciesReferenceWeight instead of Species public class SpeciesReferenceWeight : Entity { public virtual Species Species { get; set; } public virtual int ReferenceWeight { get; set; } public virtual int Year { get; set; } } But in that way that Capture is connected to the implementation details of the game and from my point of view a capture is still a capture even if it's not included in a game. The result I'm aiming for is like: http://hornalen.net/fishbonkern/2007/ that I wrote a couple of years ago with brute force sql and no domain model. I would be very happy for all kinds of feeback on this issue.

    Read the article

  • Drupal Ctools Form Wizard in a Block

    - by Iamjon
    Hi everyone I created a custom module that has a Ctools multi step form. It's basically a copy of http://www.nicklewis.org/using-chaos-tools-form-wizard-build-multistep-forms-drupal-6. The form works. I can see it if I got to the url i made for it. For the life of me I can't get the multistep form to show up in a block. Any clues? /** * Implementation of hook_block() * */ function mycrazymodule_block($op='list', $delta=0, $edit=array()) { switch ($op) { case 'list': $blocks[0]['info'] = t('SFT Getting Started'); $blocks[1]['info'] = t('SFT Contact US'); $blocks[2]['info'] = t('SFT News Letter'); return $blocks; case 'view': switch ($delta){ case '0': $block['subject'] = t('SFT Getting Started Subject'); $block['content'] = mycrazymodule_wizard(); break; case '1': $block['subject'] = t('SFT Contact US Subject'); $block['content'] = t('SFT Contact US content'); break; case '2': $block['subject'] = t('SFT News Letter Subject'); $block['content'] = t('SFT News Letter cONTENT'); break; } return $block; } } /** * Implementation of hook_menu(). */ function mycrazymodule_menu() { $items['hellocowboy'] = array( 'title' = 'Two Step Form', 'page callback' = 'mycrazymodule_wizard', 'access arguments' = array('access content') ); return $items; } /** * menu callback for the multistep form * step is whatever arg one is -- and will refer to the keys listed in * $form_info['order'], and $form_info['forms'] arrays */ function mycrazymodule_wizard() { $step = arg(1); // required includes for wizard $form_state = array(); ctools_include('wizard'); ctools_include('object-cache'); // The array that will hold the two forms and their options $form_info = array( 'id' = 'getting_started', 'path' = "hellocowboy/%step", 'show trail' = FALSE, 'show back' = FALSE, 'show cancel' = false, 'show return' =false, 'next text' = 'Submit', 'next callback' = 'getting_started_add_subtask_next', 'finish callback' = 'getting_started_add_subtask_finish', 'return callback' = 'getting_started_add_subtask_finish', 'order' = array( 'basic' = t('Step 1: Basic Info'), 'lecture' = t('Step 2: Choose Lecture'), ), 'forms' = array( 'basic' = array( 'form id' = 'basic_info_form' ), 'lecture' = array( 'form id' = 'choose_lecture_form' ), ), ); $form_state = array( 'cache name' = NULL, ); // no matter the step, you will load your values from the callback page $getstart = getting_started_get_page_cache(NULL); if (!$getstart) { // set form to first step -- we have no data $step = current(array_keys($form_info['order'])); $getstart = new stdClass(); //create cache ctools_object_cache_set('getting_started', $form_state['cache name'], $getstart); //print_r($getstart); } //THIS IS WHERE WILL STORE ALL FORM DATA $form_state['getting_started_obj'] = $getstart; // and this is the witchcraft that makes it work $output = ctools_wizard_multistep_form($form_info, $step, $form_state); return $output; } function basic_info_form(&$form, &$form_state){ $getstart = &$form_state['getting_started_obj']; $form['firstname'] = array( '#weight' = '0', '#type' = 'textfield', '#title' = t('firstname'), '#size' = 60, '#maxlength' = 255, '#required' = TRUE, ); $form['lastname'] = array( '#weight' = '1', '#type' = 'textfield', '#title' = t('lastname'), '#required' = TRUE, '#size' = 60, '#maxlength' = 255, ); $form['phone'] = array( '#weight' = '2', '#type' = 'textfield', '#title' = t('phone'), '#required' = TRUE, '#size' = 60, '#maxlength' = 255, ); $form['email'] = array( '#weight' = '3', '#type' = 'textfield', '#title' = t('email'), '#required' = TRUE, '#size' = 60, '#maxlength' = 255, ); $form['newsletter'] = array( '#weight' = '4', '#type' = 'checkbox', '#title' = t('I would like to receive the newsletter'), '#required' = TRUE, '#return_value' = 1, '#default_value' = 1, ); $form_state['no buttons'] = TRUE; } function basic_info_form_validate(&$form, &$form_state){ $email = $form_state['values']['email']; $phone = $form_state['values']['phone']; if(valid_email_address($email) != TRUE){ form_set_error('Dude you have an error', t('Where is your email?')); } //if (strlen($phone) 0 && !ereg('^[0-9]{1,3}-[0-9]{3}-[0-9]{3,4}-[0-9]{3,4}$', $phone)) { //form_set_error('Dude the phone', t('Phone number must be in format xxx-xxx-nnnn-nnnn.')); //} } function basic_info_form_submit(&$form, &$form_state){ //Grab the variables $firstname =check_plain ($form_state['values']['firstname']); $lastname = check_plain ($form_state['values']['lastname']); $email = check_plain ($form_state['values']['email']); $phone = check_plain ($form_state['values']['phone']); $newsletter = $form_state['values']['newsletter']; //Send the form and Grab the lead id $leadid = send_first_form($lastname, $firstname, $email,$phone, $newsletter); //Put into form $form_state['getting_started_obj']-firstname = $firstname; $form_state['getting_started_obj']-lastname = $lastname; $form_state['getting_started_obj']-email = $email; $form_state['getting_started_obj']-phone = $phone; $form_state['getting_started_obj']-newsletter = $newsletter; $form_state['getting_started_obj']-leadid = $leadid; } function choose_lecture_form(&$form, &$form_state){ $one = 'event 1' $two = 'event 2' $three = 'event 3' $getstart = &$form_state['getting_started_obj']; $form['lecture'] = array( '#weight' = '5', '#default_value' = 'two', '#options' = array( 'one' = $one, 'two' = $two, 'three' = $three, ), '#type' = 'radios', '#title' = t('Select Workshop'), '#required' = TRUE, ); $form['attendees'] = array( '#weight' = '6', '#default_value' = 'one', '#options' = array( 'one' = t('I will be arriving alone'), 'two' =t('I will be arriving with a guest'), ), '#type' = 'radios', '#title' = t('Attendees'), '#required' = TRUE, ); $form_state['no buttons'] = TRUE; } /** * Same idea as previous steps submit * */ function choose_lecture_form_submit(&$form, &$form_state) { $workshop = $form_state['values']['lecture']; $leadid = $form_state['getting_started_obj']-leadid; $attendees = $form_state['values']['attendees']; $form_state['getting_started_obj']-lecture = $workshop; $form_state['getting_started_obj']-attendees = $attendees; send_second_form($workshop, $attendees, $leadid); } /*----PART 3 CTOOLS CALLBACKS -- these usually don't have to be very unique ---------------------- */ /** * Callback generated when the add page process is finished. * this is where you'd normally save. */ function getting_started_add_subtask_finish(&$form_state) { dpm($form_state); $getstart = &$form_state['getting_started_obj']; drupal_set_message('mycrazymodule '.$getstart-name.' successfully deployed' ); //Get id // Clear the cache ctools_object_cache_clear('getting_started', $form_state['cache name']); $form_state['redirect'] = 'hellocowboy'; } /** * Callback for the proceed step * */ function getting_started_add_subtask_next(&$form_state) { dpm($form_state); $getstart = &$form_state['getting_started_obj']; $cache = ctools_object_cache_set('getting_started', $form_state['cache name'], $getstart); } /*----PART 4 CTOOLS FORM STORAGE HANDLERS -- these usually don't have to be very unique ---------------------- */ /** * Remove an item from the object cache. */ function getting_started_clear_page_cache($name) { ctools_object_cache_clear('getting_started', $name); } /** * Get the cached changes to a given task handler. */ function getting_started_get_page_cache($name) { $cache = ctools_object_cache_get('getting_started', $name); return $cache; } //Salesforce Functions function send_first_form($lastname, $firstname,$email,$phone, $newsletter){ $send = array("LastName" = $lastname , "FirstName" = $firstname, "Email" = $email ,"Phone" = $phone , "Newsletter__c" =$newsletter ); $sf = salesforce_api_connect(); $response = $sf-client-create(array($send), 'Lead'); dpm($response); return $response-id; } function send_second_form($workshop, $attendees, $leadid){ $send = array("Id" = $leadid , "Number_Of_Pepole__c" = "2" ); $sf = salesforce_api_connect(); $response = $sf-client-update(array($send), 'Lead'); dpm($response, 'the final response'); return $response-id; }

    Read the article

  • Surfing the internet while downloading becomes painful

    - by Mehper C. Palavuzlar
    When I try to surf the internet while downloading files (http based, torrent etc.), it becomes painful to open web pages since download traffic is mostly allocated for downloads. Is there a program that can manage this process so that when I surf the weight will be given to internet browser, and when the browser is idle, the weight will be on the download side? I'm using Firefox 3.6.2 on Win7, so any good Firefox addons or Windows based freewares are acceptable.

    Read the article

  • linux multipath routing load balance

    - by user52883
    I would like to know how to load balance two Business DLS links which have fixed IPs. I believe it would look something like this: ip route add default scope global \ nexthop via gatewayDLS1 dev interface1 weight 1 \ nexthop via gatewayDLS2 dev interface2 weight 1 Is this be all I need in order to get multipath routing? Please, give me a more detailed answer if possible, thanks you.

    Read the article

  • Can capistrano or fabric be used to setup a server from scratch?

    - by Blankman
    I'm hoping there is a light weight, command line utility that I could use to setup a server from scratch. I like python's fabric or ruby's capistrano but from what I was reading they are more used for deployment purposes and not setting up apache, mysql, update patches etc. I know there are other tools like puppet, but I don't want to setup a master/slave for servers etc., I was hoping there was a more light-weight tool for this.

    Read the article

  • How do I get preferences to work in Android?

    - by Dan T
    I've really been struggling through this. New to Java/Android. I'm writing my first app and this is the first thing that has taken me longer than a couple days of searching to figure out. Here's the setup: It's a BAC calculator / drink counter: A formula is used to calculate the BAC. Here's the forumla: Bac = ((StandardDrinks / 2) * (GenderConstant / Weight)) - (0.017 * Hours); So as you can see, being able to modify the gender and weight will produce more accurate and personalized results. So I have them as doubles: double GenderConstant = 7.5; //9 for female double Weight = 180; To change these variables I would like the person to be able to go into the settings and choose different values. I have these things set up, but not linked to the variables shown above because I cannot for the life of me figure out how. Here they are: I press the menu button and this pops up. Great. I'll click Settings. Now the preferences pops up. Here is my preferences.xml: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="Personal Settings"> <ListPreference android:title="Gender" android:summary="Verify or deny the presence of a Y chromosome." android:key="genderPref" android:defaultValue="male" android:entries="@array/genderArray" android:entryValues="@array/genderValues" /> <ListPreference android:title="Weight" android:summary="How much the planet pulls on you, in pounds." android:key="weightPref" android:defaultValue="180" android:entries="@array/weightArray" android:entryValues="@array/weightValues" /> </PreferenceCategory> <PreferenceCategory android:title="Drink Settings"> <ListPreference android:title="Beer Size" android:summary="The volume of your beer, in ounces." android:key="beerPref" android:defaultValue="12" android:entries="@array/beerArray" android:entryValues="@array/beerValues" /> <ListPreference android:title="Shot Size" android:summary="The volume of your shot, in ounces." android:key="shotPref" android:defaultValue="1.5" android:entries="@array/shotArray" android:entryValues="@array/shotValues" /> <ListPreference android:title="Wine Size" android:summary="The volume of your wine, in ounces." android:key="winePref" android:defaultValue="5" android:entries="@array/wineArray" android:entryValues="@array/wineValues" /> </PreferenceCategory> </PreferenceScreen> Onward to the weight ListPreference: And that shows up. The values are stored as string-arrays in res/values/arrays.xml. Here's a sample, of just the weight ones: <string-array name="weightArray"> <item>120 lbs</item> <item>150 lbs</item> <item>180 lbs</item> <item>210 lbs</item> <item>240 lbs</item> <item>270 lbs</item> </string-array> <string-array name="weightValues"> <item>120</item> <item>150</item> <item>180</item> <item>210</item> <item>240</item> <item>270</item> </string-array> This is basically as far as I've gotten. I can click a value, sure, but it doesn't change the formula because it's not linked with the doubles I created in DrinkingBuddy.java. All of the stuff displayed in the settings are just empty shells for now, including the spinner on the main layout (the default time is just set to 1 hour) I did create a Preferences.java and have tried implementing various combinations of code found in tutorials and resources around the web, but to no avail. Here it is anyway, filled with failed attempts to make beerPref (the settings option to change how many ounces in the beer) correlate with a variable in my main class: package com.dantoth.drinkingbuddy; import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.Preference.OnPreferenceClickListener; public class Preferences extends PreferenceActivity { public static final String PREF_BEER_SIZE = "PREF_BEER_SIZE"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); //Get the custom preference Preference beerPref = (Preference) findPreference("beerPref"); beerPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { SharedPreferences customSharedPreference = getSharedPreferences("myCustomSharedPrefs", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = customSharedPreference.edit(); editor.commit(); return true; }} );} } A full on tutorial and sample code would be AWESOME as I've yet to find any reliable guides out there.

    Read the article

  • How to Transform a user's search string into a MS SQL Full-Text Search Phrase

    - by Atomiton
    I've search for answers for this and I can't seem to find an answer to what should be somewhat simple. This is related to another question I asked, but it's different. What's the best way to take a user's search phrase and throw it into a CONTAINSTABLE(table, column, @phrase, topN ) phrase? Say, for example the user inputs: Books by "Dr. Seuss" What's the best way to turn that into something that will return results in my ContainsTAble() phrase? I was previously parsing the search phrase and writing something like ISABOUT("Books" WEIGHT(1.0), "by" WEIGHT(0.9), "Dr. Seuss" WEIGHT(0.8)) as my @phrase but ISABOUT seems to be returning odd results... especially when one word searches are entered. Any Ideas?

    Read the article

  • CSS Selector not working on elements within a div

    - by stevebot
    Hi, I have the following HTML structure: <div class="formFields"> <label> Field 1: </label> <input type="text" value="" name="field1" /> </div> And my CSS selectors are as follows: #formFields {clear:both;} #formFields label {font-weight:bold;} The clear:both; is being applied to the div, but the font-weight:bold; is not being applied to the labels. How would I apply this font-weight to the labels?

    Read the article

  • pagination with css

    - by bsandrabr
    Hi I've tried every combination I can think of but I can't get this to work. Can you help? I'm trying to put some css onto my pagination and have read all the examples but they all contain so many backslashes and concatenation that I just dont know how to apply it Here is my pagination code (which works fine) along with my feeble attempt at styling it if ($st > 0) { $st3=$st; print "< Previous Page "; } $f=$st+3; for($i2=$st+1;$i2<=$f;$i2++) { $i3=$i2-3; if ($i3 0) { print "$i3 "; if($i2 % 3 == 0) { print ""; } } } $g=$st+3; for($i=$st+1;$i<=$g;$i++) { print "$i "; if($i % 3 == 0) { print ""; } } $st2=$st+2; print " Next Page "; Here is the css that I took from the website /* CSS Document */ body { background: #2D2D2D; font-family:Verdana, fantasy; font-size:13px; color: white; scrollbar-base-color: black; scrollbar-arrow-color: red; scrollbar-DarkShadow-Color: black; } a:visited,a:active,a:link { color: white;text-decoration: none; } a:hover { color: red;text-decoration: overline underline;background: none; } table,tr,td { font-family:Palatino Linotype; color: #FFFFFF;font-size: 12px; } .button { font-family:Verdana, fantasy; font-size:13; color:#FFFFFF; background-color: red; } input,textarea,dropdown{ font-family:Verdana, fantasy; font-size:13; color: #FFFFFF; background-color: #000000; border: 1px solid; } textarea,.submit input{ font-family:Verdana, fantasy; font-size:13; color:#ffffff; background-color: black; } .table { background-color:#000000; } .table3 { background-color:#000000; } .table td { color: #000000; background-color:#DEDEDE; height:22px; } .table3 td { background-color:#CCCCCC; } td .alt { background-color:#EEEEEE; height:22px; } td .h { background-image:url(tablehgrad.png); background-repeat:repeat-x; font-weight: bold; background-color: #D6D6D6; } .table th { background-image:url(tablehgrad.png); background-repeat:repeat-x; color: #000000; font-weight: bold; background-color: #D6D6D6; } .menu th { font-font-size: 12px; color: silver; background-image:url(th.png); background-repeat:repeat-x; font-weight: bold; background-color: #4B4B4B; } .stats td { font-font-size: 12px; color: white; font-weight: bold; } .menu td { font-size: 12px; text-align: center; color: white; background-image:url(tdover.png); background-repeat:repeat-x; font-weight: bold; background-color: #4B4B4B; } .menu td:hover{ color: white; background-image:url(td.png); div.pagination { padding: 3px; margin: 3px; } div.pagination a { padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #AAAADD; text-decoration: none; /* no underline */ color: #000099; } div.pagination a:hover, div.pagination a:active { border: 1px solid #000099; color: #000; } div.pagination span.current { padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #000099; font-weight: bold; background-color: #000099; color: #FFF; } div.pagination span.disabled { padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #EEE; color: #DDD; } thanks

    Read the article

  • Convert a user's search string into a MS SQL `Full-Text Query` Search Phrase

    - by Atomiton
    I've search for answers for this and I can't seem to find an answer to what should be somewhat simple. This is related to another question I asked, but it's different. What's the best way to take a user's search phrase and throw it into a CONTAINSTABLE(table, column, @phrase, topN ) phrase? Say, for example the user inputs: Books by "Dr. Seuss" What's the best way to turn that into something that will return results in my ContainsTAble() phrase? I was previously parsing the search phrase and writing something like ISABOUT("Books" WEIGHT(1.0), "by" WEIGHT(0.9), "Dr. Seuss" WEIGHT(0.8)) as my @phrase but ISABOUT seems to be returning odd results... especially when one word searches are entered. Any Ideas?

    Read the article

  • What should the SQL keyword "ISABOUT" [deprecated?] be replaced with?

    - by Atomiton
    In MS SQL Full-text search, I'm using ISABOUT in my queries. For example, this should return the top 10 ProductIDs (PK) with a RANK Field in the ProductDetails Table SELECT * FROM CONTAINSTABLE( ProductDetails, *, ISABOUT("Nikon" WEIGHT (1.0), "Cameras" Weight(0.9)), 10 ) However, according to the SQL Documentation ISABOUT is deprecated. So, I have two questions: What is ISABOUT being replaced with? DO I even NEED any extra SQL Command there? ( IOW, would just putting the search phrase 'Nikon Cameras' be better? ) What I was originally trying to accomplish here was to weight the first word the highest, then the second word lower, and keep descending to 0.5 where I would just rank the remaining words at 0.5. My logic ( and perhaps it's flawed ) was that people's most relevant search words usually happen near the beginning of a phrase ( in English ). Am I going about this the wrong way? Is there a better way? Am I asking too many questions? (^_^) Thanks all for your time...

    Read the article

  • Dynamic/runtime method creation (code generation) in Python

    - by Eli Bendersky
    Hello, I need to generate code for a method at runtime. It's important to be able to run arbitrary code and have a docstring. I came up with a solution combining exec and setattr, here's a dummy example: class Viking(object): def __init__(self): code = ''' def dynamo(self, arg): """ dynamo's a dynamic method! """ self.weight += 1 return arg * self.weight ''' self.weight = 50 d = {} exec code.strip() in d setattr(self.__class__, 'dynamo', d['dynamo']) if __name__ == "__main__": v = Viking() print v.dynamo(10) print v.dynamo(10) print v.dynamo.__doc__ Is there a better / safer / more idiomatic way of achieving the same result?

    Read the article

  • nHibernate HQL dynamic Instantiation question

    - by Rey
    Hello all, I can't find what's going on with the following nHibernate HQL. here's my VB.Net code: Return _Session.GetNamedQuery("PersonAnthroSummary").SetInt32(0, 2).UniqueResult() My Named Query: <sql-query name="PersonAnthroSummary"> select New PersonAnthroSummary( Anthro.Height, Anthro.Weight ) from PersonAnthroContact as Anthro where Anthro.ID = ? </sql-query> and i am importing the DTO class: <import class="xxxxxxx.DataServices.PersonAnthroSummary, xxxxxxxxx.DataServices"/> PersonAnthroSummary has a constructor that will take height and weight arguments. when i test this, nHibernate throwing following exception: {"Incorrect syntax near 'Anthro'."} and generated QueryString is: "select New PersonAnthroSummary( Anthro.Height, Anthro.Weight ) from PersonAnthroContact as Anthro where Anthro.ID = @p0" Can some one tell me what i'm doing wrong here?

    Read the article

  • What's the best way to normalize scores for ranking things?

    - by beagleguy
    hi all, I'm curious how to do normalizing of numbers for a ranking algorithm let's say I want to rank a link based on importance and I have two columns to work with so a table would look like url | comments | views now I want to rank comments higher than views so I would first think to do comments*3 or something to weight it, however if there is a large view number like 40,000 and only 4 comments then the comments weight gets dropped out. So I'm thinking I have to normalize those scores down to a more equal playing field before I can weight them. Any ideas or pointers to how that's usually done? thanks

    Read the article

  • Problem with building tree bottom up

    - by Esmond
    Hi, I have problems building a binary tree from the bottom up. THe input of the tree would be internal nodes of the trees with the children of this node being the leaves of the eventual tree. So initially if the tree is empty the root would be the first internal node. Afterwards, The next internal node to be added would be the new root(NR), with the old root(OR) being one of the child of NR. And so on. The problem i have is that whenever i add a NR, the children of the OR seems to be lost when i do a inOrder traversal. This is proven to be the case when i do a getSize() call which returns the same number of nodes before and after addNode(Tree,Node) Any help with resolving this problem is appreciated edited with the inclusion of node class code. both tree and node classes have the addChild methods because i'm not very sure where to put them for it to be appropriated. any comments on this would be appreciated too. The code is as follows: import java.util.*; public class Tree { Node root; int size; public Tree() { root = null; } public Tree(Node root) { this.root = root; } public static void setChild(Node parent, Node child, double weight) throws ItemNotFoundException { if (parent.child1 != null && parent.child2 != null) { throw new ItemNotFoundException("This Node already has 2 children"); } else if (parent.child1 != null) { parent.child2 = child; child.parent = parent; parent.c2Weight = weight; } else { parent.child1 = child; child.parent = parent; parent.c1Weight = weight; } } public static void setChild1(Node parent, Node child) { parent.child1 = child; child.parent = parent; } public static void setChild2(Node parent, Node child) { parent.child2 = child; child.parent = parent; } public static Tree addNode(Tree tree, Node node) throws ItemNotFoundException { Tree tree1; if (tree.root == null) { tree.root = node; } else if (tree.root.getSeq().equals(node.getChild1().getSeq()) || tree.root.getSeq().equals(node.getChild2().getSeq())) { Node oldRoot = tree.root; oldRoot.setParent(node); tree.root = node; } else { //form a disjoint tree and merge the 2 trees tree1 = new Tree(node); tree = mergeTree(tree, tree1); } System.out.print("addNode2 = "); if(tree.root != null ) { Tree.inOrder(tree.root); } System.out.println(); return tree; } public static Tree mergeTree(Tree tree, Tree tree1) { String root = "root"; Node node = new Node(root); tree.root.setParent(node); tree1.root.setParent(node); tree.root = node; return tree; } public static int getSize(Node root) { if (root != null) { return 1 + getSize(root.child1) + getSize(root.child2); } else { return 0; } } public static boolean isEmpty(Tree Tree) { return Tree.root == null; } public static void inOrder(Node root) { if (root != null) { inOrder(root.child1); System.out.print(root.sequence + " "); inOrder(root.child2); } } } public class Node { Node child1; Node child2; Node parent; double c1Weight; double c2Weight; String sequence; boolean isInternal; public Node(String seq) { sequence = seq; child1 = null; c1Weight = 0; child2 = null; c2Weight = 0; parent = null; isInternal = false; } public boolean hasChild() { if (this.child1 == null && this.child2 == null) { this.isInternal = false; return isInternal; } else { this.isInternal = true; return isInternal; } } public String getSeq() throws ItemNotFoundException { if (this.sequence == null) { throw new ItemNotFoundException("No such node"); } else { return this.sequence; } } public void setChild(Node child, double weight) throws ItemNotFoundException { if (this.child1 != null && this.child2 != null) { throw new ItemNotFoundException("This Node already has 2 children"); } else if (this.child1 != null) { this.child2 = child; this.c2Weight = weight; } else { this.child1 = child; this.c1Weight = weight; } } public static void setChild1(Node parent, Node child) { parent.child1 = child; child.parent = parent; } public static void setChild2(Node parent, Node child) { parent.child2 = child; child.parent = parent; } public void setParent(Node parent){ this.parent = parent; } public Node getParent() throws ItemNotFoundException { if (this.parent == null) { throw new ItemNotFoundException("This Node has no parent"); } else { return this.parent; } } public Node getChild1() throws ItemNotFoundException { if (this.child1 == null) { throw new ItemNotFoundException("There is no child1"); } else { return this.child1; } } public Node getChild2() throws ItemNotFoundException { if (this.child2 == null) { throw new ItemNotFoundException("There is no child2"); } else { return this.child2; } } }

    Read the article

  • Integers in TextNodes w/ Python minidom

    - by PylonsN00b
    I am working on an API using SOAP and WSDL. The WSDL expects integers to come through. I am fairly new to ALL of this, and constructing XML in Python. I have chosen to use minidom to create my SOAP message. So using minidom, to get a value into a node I found I have to do this: weight_node = xml_file.createElement("web:Weight") weight_contents = xml_file.createTextNode(weight) weight_node.appendChild(weight_contents) So say weight needs to go in as an integer and IS an integer. The function is 'createTextNode' does this mean its going to be text, or what I put in there has to be text? Again I am fairly new to all of this. So if what I have explained seems way off base, please speak up.

    Read the article

  • How to override form just on one page?

    - by user363036
    OK so this is my hook form alter function.It is causing all the registration forms on site to be over written which I do not want as I just want it on this page. function special_registration_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'user_register') { drupal_set_title(t('Custom registration')); $form['firstname'] = array('#type' = 'textfield', '#title' = t('First Name: *'), '#required' = TRUE, '#size' = 45, '#weight' = - 100,); $form['lastname'] = array('#type' = 'textfield', '#title' = t('Last Name: *'), '#required' = TRUE, '#size' = 45, '#weight' = - 99,); } I only first name and last name to be captured and stored in a different table just on this page. On other pages I just want the good old fashioned form. Do I still need to change the weight? I know I am missing something elementary.

    Read the article

  • Where to put conditionals in ANSI-syntax SQL queries

    - by RenderIn
    What's the difference between these two queries? I've been resistant to jumping on the ANSI-syntax bandwagon because I have not been able to unravel various syntactical ambiguities. Is 1) returning the product of the join and only then filtering out those joined records which have weight = 500? And is 2) filtering out those prior to the join? Is 2 bad syntax? Why might I use that? 1: SELECT SOMETHING FROM FOO INNER JOIN BAR ON FOO.NAME = BAR.NAME WHERE BAR.WEIGHT < 500 2: SELECT SOMETHING FROM FOO INNER JOIN BAR ON FOO.NAME = BAR.NAME AND BAR.WEIGHT < 500

    Read the article

  • How to use NSObject subclass?

    - by Jon
    So I've created a subclass of NSObject called Query @interface Query : NSObject @property (nonatomic, assign) NSNumber *weight; @property (nonatomic, assign) NSNumber *bodyFat; @property (nonatomic, assign) NSNumber *activityLevel; @end Is this correct for setting the object's property? In VC1: BodyFatViewController *aViewController = [[BodyFatViewController alloc]init]; aViewController.query = self.query; [self.navigationController pushViewController:aViewController animated:YES]; In VC2: - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { Query *anQuery = [[Query alloc]init]; anQuery.bodyFat = [self.bodyFatArray objectAtIndex:row]; anQuery.weight = self.query.weight; self.query = anQuery; }

    Read the article

  • Maintaining the position of columns in Grails/GORM

    - by firnnauriel
    Is there a way to fix the position of the columns in a domain? I have this domain: class SnbrActVector { int nid String term double weight static mapping = { version false id(generator: 'assigned') } static constraints = { nid(blank:false) term(blank:false) weight(blank:false) } } This is the schema of the table generated: CREATE TABLE `fractor_grailsDEV`.`snbr_act_vector` ( `id` bigint(20) NOT NULL, `weight` double NOT NULL, `term` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `nid` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci It seems that the order of the columns were reversed. Is there a way to make it like this? (order is nid, term, weight) CREATE TABLE `fractor_grailsDEV`.`snbr_act_vector` ( `id` bigint(20) NOT NULL, `nid` int(11) NOT NULL, `term` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `weight` double NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

    Read the article

  • Multi "column" DataGridView C#

    - by Wesley
    I have a DataGridView that's bound to a DataSet. It has columns DateCreated, Weight, DateUsed. Those three columns do not take up much horizontal space on DataGridView that is nearly full screen. Is it possible to have those columns wrap back to the top if the view is wide enough to support a second group of those colums. So across the header it would read DateCreated, Weight, DateUsed, DateCreated, Weight, DateUsed. Then when a row is clicked, only 3 cells would be highlighted, not all six. Is there something that can provide this functionality?

    Read the article

  • PHP memcache - check if any server is available in pool?

    - by Industrial
    Hi everyone, I have the following code: $cluster['local'] = array('host' => '192.168.1.1', 'port' => '11211', 'weight' => 50); $cluster['local2'] = array('host' => '192.168.1.2', 'port' => '11211', 'weight' => 50); $this->memcache = new Memcache; foreach ($this->cluster() as $cluster) { $this->memcache->addServer($cluster['host'], $cluster['port'], $this->persistent, $cluster['weight'], 10, 10, TRUE , 'failure' ); } I would like to make a function that checks if any of my servers in my memcache Pool is available. How could this be done?

    Read the article

  • Insert Statment with Case for avoid duplicate record insertion

    - by rama
    I have written the below SP for Precheck for Duplicate records before insert into Table . but it is not allow me yo write insert staement inside the CASE . how can I write Stored Procedure for fist Check the value @Ordername into table After that if it is not present then it should inserted into Database . CREATE PROCEDURE [Test Procedure ] ( @section varchar(70), @mark varchar(70), @qty decimal(18,2), @Weight decimal(18,2), @dateupdateremark int, @OrderName varchar(70) ) AS BEGIN SET NOCOUNT ON; select case(@OrderName) when (select OrderName from dbo.tbl_insertxmldetails where(@OrderName) not in (select OrderName from tbl_insertxmldetails)) then insert into dbo.tbl_insertxmldetails (Section, Mark, QTY,Weight,Dateupdateremark ,OrderName,SystemDate) values (@Section, @Mark, @QTY,@Weight, @Dateupdateremark,@OrderName,GETDATE()) else 'File already Exists' end

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >