Posts

gfortran - random number generator in fortran -

gfortran - random number generator in fortran - i testing rng code mentioned in link (fortran 77 code): https://www.cisl.ucar.edu/zine/96/spring/articles/3.random-6.html applies park & miller algorithm. the function phone call of programme is call srand(seed) x=rand() however programme not seem respond seeding srand(), i.e., x-value unaffected initial seeding, , equal ~0.218. suspect has definition of mutual block , info block, value of x equivalent putting seed 123456789, initialization value defined in datablock. any ideas? i compiling gfortran. ok, problem original srand , rand may called. renamed functions srand2 , rand2 , start work expected. for seed = 1 result 7.82636926e-06 , seed = 2 result 1.56527385e-05 . checked in gfortran , in intel's fortran. fortran gfortran prng fortran-common-block

matlab - How to generate random matrix without repetition in rows and cols? -

matlab - How to generate random matrix without repetition in rows and cols? - how generate random matrix without repetition in rows , cols specific range example (3x3): range 1 3 2 1 3 3 2 1 1 3 2 example (4x4): range 1 4 4 1 3 2 1 3 2 4 3 2 4 1 2 4 1 3 this algorithm trick, assuming want contain elements between 1 , n %// elements contained, no 0 allowed = [1 2 3 4]; %// possible permutations , size n = numel(a); %// initialization output = zeros(1,n); ii = 1; while ii <= n; %// random permuation of input vector b = a(randperm(n)); %// concatenate found values temp = [output; b]; %// check if row chosen in iteration exists if ~any( arrayfun(@(x) numel(unique(temp(:,x))) < ii+1, 1:n) ) %// if not, append output = temp; %// increment counter ii = ii+1; end end output = output(2:end,:) %// delete first row zeros it won't fastest implementation. curios see others. computation time in...

regex - Powershell Find String Between Characters and Replace -

regex - Powershell Find String Between Characters and Replace - in powershell script, have hashtable contains personal information. hashtable looks like {first = "james", lastly = "brown", phone = "12345"...} using hashtable, replace strings in template text file. each string matches @key@ format, want replace string value correspond key in hashtable. here sample input , output: input.txt my first name @first@ , lastly name @last@. phone call me @ @phone@ output.txt my first name james , lastly name brown. phone call me @ 12345 could advise me how homecoming "key" string between "@"s can find value string replacement function? other ideas problem welcomed. you pure regex, sake of readability, doing more code regex: class="lang-poweshell prettyprint-override"> $tmpl = 'my first name @first@ , lastly name @last@. phone call me @ @phone@' $h = @{ first = "jame...

java - Hibernate collection update foiled by unique index -

java - Hibernate collection update foiled by unique index - i'm trying move kid object 1 parent another, in database controlled hibernate. i'm getting error on table created , controlled hibernate through @onetomany annotation. knows way around this. i have 2 objects, 1 containing list of other. let's phone call them kennel , dog. i'm doing moving dog 1 kennel kennel : dog dog = dogservice.getdog(dogid); kennel oldkennel = dog.getkennel(); if (oldkennel.getdogs().contains(dog)) { oldkennel.getdogs().remove(dog); } kennel newkennel = kennelservice.getkennel(newkennelid); newkennel.getdogs().add(dog); dog.setkennel(newkennel); there 3 tables involved: -- table mapped kennel object table kennels (kennel_id int) -- table bring together table controlled hibernate table kennels_dogs (kennels_kennel_id int, dogs_dog_id int) -- table mapped dog object table dogs (dog_id int) the specific error i'm g...

node.js - How to get Meteor's MongoDB URL from javascript -

node.js - How to get Meteor's MongoDB URL from javascript - i'm writing meteor smart bundle wrapper npm module called agenda. agenda naturally doesn't know it's working meteor, need manually give mongodb url. can url typing meteor mongo -u , i'd script automatically users of plugin don't have worry changing manually. how can this? mongo url stored in environment variable called mongo_url. in meteor can access env variables process.env object (on server). can process.env.mongo_url property javascript node.js mongodb meteor

routing - How to create AngularJS Route with dashes instead of slashes -

routing - How to create AngularJS Route with dashes instead of slashes - is possible create angular routes dashes instead of slashes, , variable content in url fragment? example: in angular phone tutorial, urls this, e.g: http://angular.github.io/angular-phonecat/step-11/app/#/phones/motorola-xoom this implemented via route provider such as: when('/phones/:phoneid', { templateurl: 'partials/phone-detail.html', controller: 'phonedetailctrl' }) what i'd have urls more like: http://angular.github.io/angular-phonecat/step-11/app/#/phones/{{manufacturer}}--{{devicename}}--{{phoneid}} where {{phoneid}} numerical database key , {{manufacturer}} text vary phone phone. because need numerical key drive database want manufacturer & devicename text (or equivalent) in url seo purposes.... effectively i'd in angular routes can in htaccess files, i'd like: rewriterule ^(.)--by--(.)--(.*)$ phone.php?mfg=$1&devicename=$2...

c# - Block insert loop error !dbobji.cpp@8638: eNotOpenForWrite -

c# - Block insert loop error !dbobji.cpp@8638: eNotOpenForWrite - good day, i'm creating programme few calculations , insert block @ point user clicks on, repeats calc , insert @ other point user clicks on until user cancels (see programme below). the programme correctly @ first point user clicks on. yet sec time through while loop, after user clicks on point, programme causes fatal error , crashes autocad without inserting block, crash error message: “ internal error: !dbobji.cpp@8638: enotopenforwrite”. would please go through , explain me problem is? thank you, using system; using autodesk.autocad.runtime; using autodesk.autocad.applicationservices; using autodesk.autocad.databaseservices; using autodesk.autocad.geometry; using autodesk.autocad.editorinput; using system.collections.generic; using system.linq; [assembly: commandclass(typeof(level_arrow.program))] namespace level_arrow { public class programme { [commandmethod("levelcal...