我无法完全理解k-means ++算法.我很感兴趣的是如何挑选出第一个k质心(剩下的就像在原始的k-means中).
我将欣赏一步一步的解释和一个例子.维基百科中的那个还不够清楚.一个评论很好的源代码也会有所帮助.如果您使用的是6个阵列,那么请告诉我们哪个阵列是为了什么.
language-agnostic algorithm cluster-analysis machine-learning k-means
"Async.Parallel"结构真的有助于在多核系统上更快地进行计算吗?.NET TPL"任务"是否以某种方式涉及到这里?
open System;
let key = Console.ReadKey(true);
let start = System.DateTime.Now
let pmap f l = seq { for a in l do yield async {return f a} } |> Async.Parallel |> Async.RunSynchronously
let map f l = seq {for a in l do yield f a}
let work f l =
match key.KeyChar with
| '1' -> pmap f l
| '2' -> Seq.toArray (map f l)
| _ -> [||]
let result = work (fun x -> …Run Code Online (Sandbox Code Playgroud) 我想在F#中实现以下C#接口:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.Addins;
[TypeExtensionPoint]
public interface ISparqlCommand
{
string Name { get; }
object Run(Dictionary<string, string> NamespacesDictionary, org.openrdf.repository.Repository repository, params object[] argsRest);
}
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的,但它给了我:"表达式中或之前的不完整的结构化构造"
#light
module Module1
open System
open System.Collections.Generic;
type MyClass() =
interface ISparqlCommand with
member this.Name =
"Finding the path between two tops in the Graph"
member this.Run(NamespacesDictionary, repository, argsRest) =
new System.Object
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?也许压痕是错的?
我想在相应值列表上执行函数列表:
let f1 x = x*2;;
let f2 x = x+70;;
let conslist = [f1;f2];;
let pmap2 list1 list2 =
seq { for i in 0..1 do yield async { return list1.[i] list2.[i] } }
|> Async.Parallel
|> Async.RunSynchronously;;
Run Code Online (Sandbox Code Playgroud)
结果:
seq { for i in 0..1 do yield async { return list1.[i] list2.[i] } }
----------------------------------------------^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)
stdin(213,49):错误FS0752:运算符'expr.[idx]'已被用作基于此程序点之前的信息的不确定类型的对象.考虑添加其他类型约束
我想执行:pmap2 conslist [5; 8] ;; (在平行下)
应该使用什么字体?如何显示特定的象形文字?.NET 控件支持这个吗?.NET 字符和字符串类型是否有一些限制?
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
char **p;
p = (char **)malloc(100);
p[0] = (char *)"Apple"; // or write *p, points to location of 'A'
p[1] = (char *)"Banana"; // or write *(p+1), points to location of 'B'
cout << *p << endl; //Prints the first pointer
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中:
p[0] = (char *)"Apple";
Run Code Online (Sandbox Code Playgroud)
似乎会自动保留内存。没有malloc。这是C / C ++标准还是特定于编译器?
更新1 我实际上对它在C中然后在C ++中的状态很感兴趣。只是我没有为上述代码安装C编译器,因此我使用了C ++。
那么在STACK上分配p指向HEAP中的一个内存块(数组),其中每个元素都指向(是一个指针)指向DATA段中的文字?哇!
char* str ="Hello";
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,文字“ Hello”存储在DATA段中,并且是只读的。所以总是声明它不是更好:
const char* str = "Hello";
Run Code Online (Sandbox Code Playgroud)
避免使用不正确的代码,例如:
*(str+1) = 't';
Run Code Online (Sandbox Code Playgroud)