Create Array from list of indices/valuesIs there a faster way to create a matrix of indices from ragged data?Efficient submatrix swaps for large sparse matrixHow to create automatically some matrices for symbolic manipulation?How to partition a 2-D array properly?How to convert an output of a matrix into a PNG image?Plotting points using adjacency matrixFind the indices of elements which are larger than 10 in a listExtract a matrix from a ListInterpolationReplace elements of a matrix with zeros using another matrixConverting from “matrix” data into “coordinate” data
Use chown -R while excluding one or two files
Operation Unz̖̬̜̺̬a͇͖̯͔͉l̟̭g͕̝̼͇͓̪͍o̬̝͍̹̻
Vienna To Graz By Rail
Does this sentence I constructed with my junior high school latin work? I write online advertising and want to come off as snobby as possible
At which point can a system be compromised when downloading archived data from an untrusted source?
Random piece of plastic
Can a Resident Assistant be told to ignore a lawful order?'
How fast does a character need to move to be effectively invisible?
Is it legal for a supermarket to refuse to sell an adult beer if an adult with them doesn’t have their ID?
What would be the safest way to drop thousands of small, hard objects from a typical, high wing, GA airplane?
Is there a typesafe way to get a Database.QueryLocator?
ArcPy Delete Function not working inside for loop?
Generating a PIN from cryptographic bytes
Cover a cube with four-legged walky-squares!
Do dragons smell of lilacs?
What "fuel more powerful than anything the West (had) in stock" put Laika in orbit aboard Sputnik 2?
Coverting list of string into integers and reshaping the original list
What are the first usages of "thong" as a wearable item of clothing, both on the feet and on the waist?
Is straight-up writing someone's opinions telling?
A scene of Jimmy diversity
Why is the total probability theorem expressed in this way?
What happens if there is no space for entry stamp in the passport for US visa?
What does it actually mean to have two time dimensions?
How Can I Process Untrusted Data Sources Securely?
Create Array from list of indices/values
Is there a faster way to create a matrix of indices from ragged data?Efficient submatrix swaps for large sparse matrixHow to create automatically some matrices for symbolic manipulation?How to partition a 2-D array properly?How to convert an output of a matrix into a PNG image?Plotting points using adjacency matrixFind the indices of elements which are larger than 10 in a listExtract a matrix from a ListInterpolationReplace elements of a matrix with zeros using another matrixConverting from “matrix” data into “coordinate” data
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
Is there is a performat way to convert something like
0,0,a,0,1,c,1,0,d,1,1,e
into
a,b,c,d
The indices are not always orderes and the only solution I can think of is searching for the maximum indices, create a matrix filled with 0 and use map afterwards to modify the matrix.
Is there is a better way?
Thank you,
Martin
list-manipulation matrix conversion
New contributor
$endgroup$
add a comment |
$begingroup$
Is there is a performat way to convert something like
0,0,a,0,1,c,1,0,d,1,1,e
into
a,b,c,d
The indices are not always orderes and the only solution I can think of is searching for the maximum indices, create a matrix filled with 0 and use map afterwards to modify the matrix.
Is there is a better way?
Thank you,
Martin
list-manipulation matrix conversion
New contributor
$endgroup$
2
$begingroup$
I assume that when you write0,0,a,0,1,c,1,0,d,1,1,e
you actually mean0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d
, Please check that the input is correct.
$endgroup$
– rhermans
11 hours ago
add a comment |
$begingroup$
Is there is a performat way to convert something like
0,0,a,0,1,c,1,0,d,1,1,e
into
a,b,c,d
The indices are not always orderes and the only solution I can think of is searching for the maximum indices, create a matrix filled with 0 and use map afterwards to modify the matrix.
Is there is a better way?
Thank you,
Martin
list-manipulation matrix conversion
New contributor
$endgroup$
Is there is a performat way to convert something like
0,0,a,0,1,c,1,0,d,1,1,e
into
a,b,c,d
The indices are not always orderes and the only solution I can think of is searching for the maximum indices, create a matrix filled with 0 and use map afterwards to modify the matrix.
Is there is a better way?
Thank you,
Martin
list-manipulation matrix conversion
list-manipulation matrix conversion
New contributor
New contributor
edited 11 hours ago
Kuba♦
110k12 gold badges217 silver badges554 bronze badges
110k12 gold badges217 silver badges554 bronze badges
New contributor
asked 11 hours ago
MartinMartin
411 bronze badge
411 bronze badge
New contributor
New contributor
2
$begingroup$
I assume that when you write0,0,a,0,1,c,1,0,d,1,1,e
you actually mean0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d
, Please check that the input is correct.
$endgroup$
– rhermans
11 hours ago
add a comment |
2
$begingroup$
I assume that when you write0,0,a,0,1,c,1,0,d,1,1,e
you actually mean0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d
, Please check that the input is correct.
$endgroup$
– rhermans
11 hours ago
2
2
$begingroup$
I assume that when you write
0,0,a,0,1,c,1,0,d,1,1,e
you actually mean 0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d
, Please check that the input is correct.$endgroup$
– rhermans
11 hours ago
$begingroup$
I assume that when you write
0,0,a,0,1,c,1,0,d,1,1,e
you actually mean 0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d
, Please check that the input is correct.$endgroup$
– rhermans
11 hours ago
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
spec = 0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
Normal @ SparseArray[# + 1 -> #2 & @@@ spec]
a, b, c, d
$endgroup$
add a comment |
$begingroup$
Also possible:
r = 0, 0, a, 0, 1, c, 1, 0, d, 1, 1, e;
SparseArray[r[[All, 1]] + 1 -> r[[All, 2]]]
$endgroup$
add a comment |
$begingroup$
(Array[#1, #2 &, 2, 2]-1)/.Rule@@@list
a, b, c, d
where
list=0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
$endgroup$
$begingroup$
I think you misinterpret the question. The index may not be limited by 2.
$endgroup$
– rhermans
8 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
);
);
Martin is a new contributor. Be nice, and check out our Code of Conduct.
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%2fmathematica.stackexchange.com%2fquestions%2f202244%2fcreate-array-from-list-of-indices-values%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
spec = 0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
Normal @ SparseArray[# + 1 -> #2 & @@@ spec]
a, b, c, d
$endgroup$
add a comment |
$begingroup$
spec = 0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
Normal @ SparseArray[# + 1 -> #2 & @@@ spec]
a, b, c, d
$endgroup$
add a comment |
$begingroup$
spec = 0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
Normal @ SparseArray[# + 1 -> #2 & @@@ spec]
a, b, c, d
$endgroup$
spec = 0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
Normal @ SparseArray[# + 1 -> #2 & @@@ spec]
a, b, c, d
answered 11 hours ago
Kuba♦Kuba
110k12 gold badges217 silver badges554 bronze badges
110k12 gold badges217 silver badges554 bronze badges
add a comment |
add a comment |
$begingroup$
Also possible:
r = 0, 0, a, 0, 1, c, 1, 0, d, 1, 1, e;
SparseArray[r[[All, 1]] + 1 -> r[[All, 2]]]
$endgroup$
add a comment |
$begingroup$
Also possible:
r = 0, 0, a, 0, 1, c, 1, 0, d, 1, 1, e;
SparseArray[r[[All, 1]] + 1 -> r[[All, 2]]]
$endgroup$
add a comment |
$begingroup$
Also possible:
r = 0, 0, a, 0, 1, c, 1, 0, d, 1, 1, e;
SparseArray[r[[All, 1]] + 1 -> r[[All, 2]]]
$endgroup$
Also possible:
r = 0, 0, a, 0, 1, c, 1, 0, d, 1, 1, e;
SparseArray[r[[All, 1]] + 1 -> r[[All, 2]]]
answered 11 hours ago
Henrik SchumacherHenrik Schumacher
65.3k5 gold badges94 silver badges180 bronze badges
65.3k5 gold badges94 silver badges180 bronze badges
add a comment |
add a comment |
$begingroup$
(Array[#1, #2 &, 2, 2]-1)/.Rule@@@list
a, b, c, d
where
list=0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
$endgroup$
$begingroup$
I think you misinterpret the question. The index may not be limited by 2.
$endgroup$
– rhermans
8 hours ago
add a comment |
$begingroup$
(Array[#1, #2 &, 2, 2]-1)/.Rule@@@list
a, b, c, d
where
list=0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
$endgroup$
$begingroup$
I think you misinterpret the question. The index may not be limited by 2.
$endgroup$
– rhermans
8 hours ago
add a comment |
$begingroup$
(Array[#1, #2 &, 2, 2]-1)/.Rule@@@list
a, b, c, d
where
list=0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
$endgroup$
(Array[#1, #2 &, 2, 2]-1)/.Rule@@@list
a, b, c, d
where
list=0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d;
answered 8 hours ago
user1066user1066
6,4482 gold badges20 silver badges33 bronze badges
6,4482 gold badges20 silver badges33 bronze badges
$begingroup$
I think you misinterpret the question. The index may not be limited by 2.
$endgroup$
– rhermans
8 hours ago
add a comment |
$begingroup$
I think you misinterpret the question. The index may not be limited by 2.
$endgroup$
– rhermans
8 hours ago
$begingroup$
I think you misinterpret the question. The index may not be limited by 2.
$endgroup$
– rhermans
8 hours ago
$begingroup$
I think you misinterpret the question. The index may not be limited by 2.
$endgroup$
– rhermans
8 hours ago
add a comment |
Martin is a new contributor. Be nice, and check out our Code of Conduct.
Martin is a new contributor. Be nice, and check out our Code of Conduct.
Martin is a new contributor. Be nice, and check out our Code of Conduct.
Martin is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Mathematica Stack Exchange!
- 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.
Use MathJax to format equations. MathJax reference.
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%2fmathematica.stackexchange.com%2fquestions%2f202244%2fcreate-array-from-list-of-indices-values%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
2
$begingroup$
I assume that when you write
0,0,a,0,1,c,1,0,d,1,1,e
you actually mean0, 0, a, 0, 1, b, 1, 0, c, 1, 1, d
, Please check that the input is correct.$endgroup$
– rhermans
11 hours ago