Objective-C Nested For Loop To Create Matrix Duplicate Entries Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Breaking out of a nested loopHow do I create delegates in Objective-C?Creating an abstract class in Objective-CCan I use break to exit multiple nested for loops?Finding eigenvectors of covariance matrix to create 3D bounding sphereCreate singleton using GCD's dispatch_once in Objective CCreating a matrix after a for loopCreating a matrix from using a nested for loop in RNested for loops results in duplicate entriesFilling in Julia matrix with nested for loops
Is it OK if I do not take the receipt in Germany?
Is there a verb for listening stealthily?
How do I deal with an erroneously large refund?
What is the ongoing value of the Kanban board to the developers as opposed to management
When speaking, how do you change your mind mid-sentence?
Trying to enter the Fox's den
When does Bran Stark remember Jamie pushing him?
Married in secret, can marital status in passport be changed at a later date?
What is the evidence that custom checks in Northern Ireland are going to result in violence?
Why these surprising proportionalities of integrals involving odd zeta values?
“Since the train was delayed for more than an hour, passengers were given a full refund.” – Why is there no article before “passengers”?
Why doesn't the university give past final exams' answers?
Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?
Can 'non' with gerundive mean both lack of obligation and negative obligation?
How was Lagrange appointed professor of mathematics so early?
Why do people think Winterfell crypts is the safest place for women, children & old people?
Should man-made satellites feature an intelligent inverted "cow catcher"?
Why aren't these two solutions equivalent? Combinatorics problem
Can the van der Waals coefficients be negative in the van der Waals equation for real gases?
Why is one lightbulb in a string illuminated?
What is the difference between 准时 and 按时?
Pointing to problems without suggesting solutions
Assertions In A Mock Callout Test
Is the Mordenkainen's Sword spell underpowered?
Objective-C Nested For Loop To Create Matrix Duplicate Entries
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Breaking out of a nested loopHow do I create delegates in Objective-C?Creating an abstract class in Objective-CCan I use break to exit multiple nested for loops?Finding eigenvectors of covariance matrix to create 3D bounding sphereCreate singleton using GCD's dispatch_once in Objective CCreating a matrix after a for loopCreating a matrix from using a nested for loop in RNested for loops results in duplicate entriesFilling in Julia matrix with nested for loops
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am working on an iOS app in objective-c (calculating inbreeding coefficient). I have a for loop nested in a for loop to create a matrix. I am getting strange output when looking for a value in the matrix so I added some logs to see if I could figure out what was going on. Trying to get the diagonal value of the matrix I printed the values being used in the calculation at one specific row/column value. Somehow my code is generating the diagonal value twice with two different values. I cannot understand how one diagonal value is being calculated twice in this code:
for(x = 0; x < results.count; x++)
//Loop through all animals to create matrix columns
NSMutableArray *rows = [[NSMutableArray alloc] init];
i = 0;
for (i = 0; i < results.count; i++)
//Loop through all animals to create matrix rows
int maleID = [[[results objectAtIndex:i] objectAtIndex:1] intValue];
int femaleID = [[[results objectAtIndex:i] objectAtIndex:2] intValue];
//NSString *animalID = [[results objectAtIndex:i] objectAtIndex:3];
//NSLog(@"animal = %@ male = %d, female = %d",animalID,maleID,femaleID);
if (i > x)
//Above diagonal calculation
//If male unknow tfemale male coefficient = 0
if (maleID==-1)
maleCOE = 0;
else
maleCOE = [[rows objectAtIndex:maleID] floatValue];
//If female unknown tfemale female coefficient = 0
if (femaleID==-1)
femaleCOE = 0;
else
femaleCOE = [[rows objectAtIndex:femaleID] floatValue];
//Calculate breeding pair COE
float breedingCOE = (maleCOE + femaleCOE)/2;
[rows addObject:[NSNumber numberWithFloat:breedingCOE]];
if (x==7 && i==15)
NSLog(@"femaleID = %d, maleID = %d, femaleCOE = %f, maleCOE = %f, breedingCOE = %f",femaleID,maleID,femaleCOE,maleCOE,breedingCOE);
if (i < x)
//If below diagonal, use prior calculated breedingCOE from above diagonal
float breedingCOE = [[[columns objectAtIndex:i] objectAtIndex:x]floatValue];
[rows addObject:[NSNumber numberWithFloat:breedingCOE]];
if (i == x)
//NSLog(@"row %d count = %lu",x,(unsigned long)rows.count);
NSString *str = [rows componentsJoinedByString:@", "];
//NSLog(@"%@",str);
//Add row to column
[columns addObject:rows];
objective-c for-loop matrix
add a comment |
I am working on an iOS app in objective-c (calculating inbreeding coefficient). I have a for loop nested in a for loop to create a matrix. I am getting strange output when looking for a value in the matrix so I added some logs to see if I could figure out what was going on. Trying to get the diagonal value of the matrix I printed the values being used in the calculation at one specific row/column value. Somehow my code is generating the diagonal value twice with two different values. I cannot understand how one diagonal value is being calculated twice in this code:
for(x = 0; x < results.count; x++)
//Loop through all animals to create matrix columns
NSMutableArray *rows = [[NSMutableArray alloc] init];
i = 0;
for (i = 0; i < results.count; i++)
//Loop through all animals to create matrix rows
int maleID = [[[results objectAtIndex:i] objectAtIndex:1] intValue];
int femaleID = [[[results objectAtIndex:i] objectAtIndex:2] intValue];
//NSString *animalID = [[results objectAtIndex:i] objectAtIndex:3];
//NSLog(@"animal = %@ male = %d, female = %d",animalID,maleID,femaleID);
if (i > x)
//Above diagonal calculation
//If male unknow tfemale male coefficient = 0
if (maleID==-1)
maleCOE = 0;
else
maleCOE = [[rows objectAtIndex:maleID] floatValue];
//If female unknown tfemale female coefficient = 0
if (femaleID==-1)
femaleCOE = 0;
else
femaleCOE = [[rows objectAtIndex:femaleID] floatValue];
//Calculate breeding pair COE
float breedingCOE = (maleCOE + femaleCOE)/2;
[rows addObject:[NSNumber numberWithFloat:breedingCOE]];
if (x==7 && i==15)
NSLog(@"femaleID = %d, maleID = %d, femaleCOE = %f, maleCOE = %f, breedingCOE = %f",femaleID,maleID,femaleCOE,maleCOE,breedingCOE);
if (i < x)
//If below diagonal, use prior calculated breedingCOE from above diagonal
float breedingCOE = [[[columns objectAtIndex:i] objectAtIndex:x]floatValue];
[rows addObject:[NSNumber numberWithFloat:breedingCOE]];
if (i == x)
//NSLog(@"row %d count = %lu",x,(unsigned long)rows.count);
NSString *str = [rows componentsJoinedByString:@", "];
//NSLog(@"%@",str);
//Add row to column
[columns addObject:rows];
objective-c for-loop matrix
Please provide a minimal example: what is the value ofresults
, what is the calculation, what is the result you want and what is the result you get.
– Willeke
Mar 23 at 10:25
I am attempting to program something like this link. There are a few calculations involved. The issue is that on a smaller dataset I seem to be getting accurate results but a larger dataset is giving inaccuracies. I am not sure how to go about sharing data without providing the entire database and app code. husdyr.kvl.dk/htm/kc/popgen/genetik/applets/tabularapp.htm
– datan3rd
Mar 25 at 10:57
add a comment |
I am working on an iOS app in objective-c (calculating inbreeding coefficient). I have a for loop nested in a for loop to create a matrix. I am getting strange output when looking for a value in the matrix so I added some logs to see if I could figure out what was going on. Trying to get the diagonal value of the matrix I printed the values being used in the calculation at one specific row/column value. Somehow my code is generating the diagonal value twice with two different values. I cannot understand how one diagonal value is being calculated twice in this code:
for(x = 0; x < results.count; x++)
//Loop through all animals to create matrix columns
NSMutableArray *rows = [[NSMutableArray alloc] init];
i = 0;
for (i = 0; i < results.count; i++)
//Loop through all animals to create matrix rows
int maleID = [[[results objectAtIndex:i] objectAtIndex:1] intValue];
int femaleID = [[[results objectAtIndex:i] objectAtIndex:2] intValue];
//NSString *animalID = [[results objectAtIndex:i] objectAtIndex:3];
//NSLog(@"animal = %@ male = %d, female = %d",animalID,maleID,femaleID);
if (i > x)
//Above diagonal calculation
//If male unknow tfemale male coefficient = 0
if (maleID==-1)
maleCOE = 0;
else
maleCOE = [[rows objectAtIndex:maleID] floatValue];
//If female unknown tfemale female coefficient = 0
if (femaleID==-1)
femaleCOE = 0;
else
femaleCOE = [[rows objectAtIndex:femaleID] floatValue];
//Calculate breeding pair COE
float breedingCOE = (maleCOE + femaleCOE)/2;
[rows addObject:[NSNumber numberWithFloat:breedingCOE]];
if (x==7 && i==15)
NSLog(@"femaleID = %d, maleID = %d, femaleCOE = %f, maleCOE = %f, breedingCOE = %f",femaleID,maleID,femaleCOE,maleCOE,breedingCOE);
if (i < x)
//If below diagonal, use prior calculated breedingCOE from above diagonal
float breedingCOE = [[[columns objectAtIndex:i] objectAtIndex:x]floatValue];
[rows addObject:[NSNumber numberWithFloat:breedingCOE]];
if (i == x)
//NSLog(@"row %d count = %lu",x,(unsigned long)rows.count);
NSString *str = [rows componentsJoinedByString:@", "];
//NSLog(@"%@",str);
//Add row to column
[columns addObject:rows];
objective-c for-loop matrix
I am working on an iOS app in objective-c (calculating inbreeding coefficient). I have a for loop nested in a for loop to create a matrix. I am getting strange output when looking for a value in the matrix so I added some logs to see if I could figure out what was going on. Trying to get the diagonal value of the matrix I printed the values being used in the calculation at one specific row/column value. Somehow my code is generating the diagonal value twice with two different values. I cannot understand how one diagonal value is being calculated twice in this code:
for(x = 0; x < results.count; x++)
//Loop through all animals to create matrix columns
NSMutableArray *rows = [[NSMutableArray alloc] init];
i = 0;
for (i = 0; i < results.count; i++)
//Loop through all animals to create matrix rows
int maleID = [[[results objectAtIndex:i] objectAtIndex:1] intValue];
int femaleID = [[[results objectAtIndex:i] objectAtIndex:2] intValue];
//NSString *animalID = [[results objectAtIndex:i] objectAtIndex:3];
//NSLog(@"animal = %@ male = %d, female = %d",animalID,maleID,femaleID);
if (i > x)
//Above diagonal calculation
//If male unknow tfemale male coefficient = 0
if (maleID==-1)
maleCOE = 0;
else
maleCOE = [[rows objectAtIndex:maleID] floatValue];
//If female unknown tfemale female coefficient = 0
if (femaleID==-1)
femaleCOE = 0;
else
femaleCOE = [[rows objectAtIndex:femaleID] floatValue];
//Calculate breeding pair COE
float breedingCOE = (maleCOE + femaleCOE)/2;
[rows addObject:[NSNumber numberWithFloat:breedingCOE]];
if (x==7 && i==15)
NSLog(@"femaleID = %d, maleID = %d, femaleCOE = %f, maleCOE = %f, breedingCOE = %f",femaleID,maleID,femaleCOE,maleCOE,breedingCOE);
if (i < x)
//If below diagonal, use prior calculated breedingCOE from above diagonal
float breedingCOE = [[[columns objectAtIndex:i] objectAtIndex:x]floatValue];
[rows addObject:[NSNumber numberWithFloat:breedingCOE]];
if (i == x)
//NSLog(@"row %d count = %lu",x,(unsigned long)rows.count);
NSString *str = [rows componentsJoinedByString:@", "];
//NSLog(@"%@",str);
//Add row to column
[columns addObject:rows];
objective-c for-loop matrix
objective-c for-loop matrix
asked Mar 22 at 13:55
datan3rddatan3rd
111
111
Please provide a minimal example: what is the value ofresults
, what is the calculation, what is the result you want and what is the result you get.
– Willeke
Mar 23 at 10:25
I am attempting to program something like this link. There are a few calculations involved. The issue is that on a smaller dataset I seem to be getting accurate results but a larger dataset is giving inaccuracies. I am not sure how to go about sharing data without providing the entire database and app code. husdyr.kvl.dk/htm/kc/popgen/genetik/applets/tabularapp.htm
– datan3rd
Mar 25 at 10:57
add a comment |
Please provide a minimal example: what is the value ofresults
, what is the calculation, what is the result you want and what is the result you get.
– Willeke
Mar 23 at 10:25
I am attempting to program something like this link. There are a few calculations involved. The issue is that on a smaller dataset I seem to be getting accurate results but a larger dataset is giving inaccuracies. I am not sure how to go about sharing data without providing the entire database and app code. husdyr.kvl.dk/htm/kc/popgen/genetik/applets/tabularapp.htm
– datan3rd
Mar 25 at 10:57
Please provide a minimal example: what is the value of
results
, what is the calculation, what is the result you want and what is the result you get.– Willeke
Mar 23 at 10:25
Please provide a minimal example: what is the value of
results
, what is the calculation, what is the result you want and what is the result you get.– Willeke
Mar 23 at 10:25
I am attempting to program something like this link. There are a few calculations involved. The issue is that on a smaller dataset I seem to be getting accurate results but a larger dataset is giving inaccuracies. I am not sure how to go about sharing data without providing the entire database and app code. husdyr.kvl.dk/htm/kc/popgen/genetik/applets/tabularapp.htm
– datan3rd
Mar 25 at 10:57
I am attempting to program something like this link. There are a few calculations involved. The issue is that on a smaller dataset I seem to be getting accurate results but a larger dataset is giving inaccuracies. I am not sure how to go about sharing data without providing the entire database and app code. husdyr.kvl.dk/htm/kc/popgen/genetik/applets/tabularapp.htm
– datan3rd
Mar 25 at 10:57
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55301163%2fobjective-c-nested-for-loop-to-create-matrix-duplicate-entries%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55301163%2fobjective-c-nested-for-loop-to-create-matrix-duplicate-entries%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please provide a minimal example: what is the value of
results
, what is the calculation, what is the result you want and what is the result you get.– Willeke
Mar 23 at 10:25
I am attempting to program something like this link. There are a few calculations involved. The issue is that on a smaller dataset I seem to be getting accurate results but a larger dataset is giving inaccuracies. I am not sure how to go about sharing data without providing the entire database and app code. husdyr.kvl.dk/htm/kc/popgen/genetik/applets/tabularapp.htm
– datan3rd
Mar 25 at 10:57