Is there a more efficient way to reorder columns in a Deedle frame than doing something like the following:
let fr2 = fr.Columns.[["colC"; "colA"; "colB"]]
It seems a bit inefficient, especially given that I have to iterate through a ton of these files every weekend. There is a related question here but doesn't seem to work for me.
How about this:
let df = Frame.ofColumns(df.Columns.Realign(newcolidx))
As this appears to me returning a new df, it might not be ideal for you.
And this Issue still remains open.
Related
I'm new to both AudioKit and stack overflow, sorry if I'm not asking this in the correct way.
I'm trying to figure out how to modulate the frequency of one AKFMOscillator with the output of another oscillator, so that they would work more like the operators of an FM synth. If I understand correctly
, AKFMOscillators have their own built in modulation source, but I'd like to be able to stack multiple modulators so that I can set up algorithms like on an FM synth, however nothing I've tried so far works.
I've gotten some results doing this:
var oscillatorOne = AKFMOscillator()
var oscillatorTwo = AKFMOscillator()
oscillatorOne.modulatingMultiplier = oscillatorTwo
but that's not really doing the right thing. Is this even possible? Thanks for any advice.
Could you explain to me what is a VGroup and how is it useful, please? I tried looking for it, but obviously to no avail, not much documentation there is. Thanks in advance.
It is basically a group of VMobjects. So say you have some equation consisting of multiple seperate Texmobjects. Then you want to move the entire thing. It would make sense to VGroup all the parts, so let entire_eq = VGroup (eq_part1, eq_part2, eq_part3) and then you would just have to move this entire_eq. This also applies for changing the colors, scaling and so fort.
This works for any kinds of VMobject.
I have a file describing people with the help of FOAF. In Jena I am trying to parse all ages from the profiles and noticed that my listStatements and listObjectsOfProperty gives me different results. I could not easily find any help from the javadocs or other documentation.
I have the following code for querying with listStatments:
StmtIterator iter = this.foafmodel.listStatements(
(Resource) null,
this.foafmodel.createProperty("http://xmlns.com/foaf/0.1/age"),
(RDFNode) null);
And this is the code for listObjectsOfProperty:
Property foafAge = this.foafmodel.createProperty("http://xmlns.com/foaf/0.1/age");
NodeIterator iter = this.foafmodel.listObjectsOfProperty(foafAge);
In this case listStatements iterator iterates 38 times while the listObjectsOfProperty only 20 times. Can someone explain to me what is the difference between these two implementations?
Let us assume that your data contains multiple triples with your property :p referencing the same object :o, like so:
:s1 :p :o .
:s2 :p :o .
At first glance, it would appear to me that listObjectsOfProperty are giving you all individuals that are referenced by your property without duplication. We can confirm this by digging into the implementation that depends on GraphUtil#listObjects(...). The code uses a Set<Node> to aggregate all of the objects. As a result, you should only get back a single iteration with the element :o.
The other method, listStatements should return to you a statement/triple for every time that property is used. In the example model above, you would/should get two results, one for each statements containing :p.
I have a simple question, that I unfortunately cannot seem to solve myself.
How to print only observations with an odd observation number from a data set?
One way you might do this is with a data step view. Assuming you have a data set named "MySASData", try this:
data my_view / view=my_view;
set MySASData;
if mod(_n_,2) = 1;
run;
proc print data=my_view;
run;
If you wanted "even" observations, you use if mod(_n_,2) = 0;. However, note that the observation numbers displayed by proc print will be relative to the view and not from the original data set.
Data step views are very useful for things like this.
What is the more efficient way?
FUserRecords[I].CurrentInput:=FUserRecords[I].CurrentInput+typedWords;
or
var userRec: TUserRec;
...
userRec:=FUserRecords[I];
userRec.CurrentInput:=userRec.CurrentInput+typedWords;
FUserRecords[I]:=userRec;
In the case you have described, the first example will be the most efficient.
Records are value types, so when you do this line:
userRec:=FUserRecords[I];
You are in fact copying the contents of the record in the array into the local variable. And when you do the reverse, you are copying the information again. If you are iterating over the array, this can end up being quite slow if your array and the records are quite large.
If you want to go down the second path, to speed things up you can manipulate the record in the array directly using a pointer to the record, like this:
type
TUserRec = record
CurrentInput: string;
end;
PUserRec = ^TUserRec;
var
LUserRec: PUserRec;
...
LUserRec := #FUserRecords[I];
LUserRec^.CurrentInput := LUserRec^.CurrentInput + typedWords;
(as discussed in the comments, the carets (^) are optional. I only added them here for completeness).
Of course I should point out that you really only need to do this if there is in fact a performance problem. It is always good to profile your application before you hand code these sorts of optimisations.
EDIT: One caveat to all the discussion on the performance issue you are looking at is that if most of your data in the records are strings, then most of any performance lost in the example you have shown will be in the string concatenation, not in the record manipulation.
Also, the strings are basically stored in the record as pointers, so the record will actually be the size of any integers etc, plus the size of the pointers for the strings. So, when you concatenate to the string, it will no increase the record size. You can basically look at the string manipulation part of your code as a separate issue to the record manipulation.
You have mentioned in your comments below, this is for storing input from multiple keyboards, I can't imagine that you will have more than 5-10 items in the array. At that size, doing these steps to optimize the code is not really going to boost the speed that much.
I believe that both your first example and the pointer-using code above will end up with approximately the same performance. You should use which ever is the easiest for you to read and understand.
N#
Faster and more readable:
with FUserRecords[I] do
CurrentInput := CurrentInput + typedWords;