⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 npoint.c

📁 Entropy-based CLIQUE算法改进
💻 C
字号:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "NPoint.h"

// Constructor
NPoint::NPoint()
{
  dim = 50;

  coord = new float[dim];
  if (coord==NULL) {
    printf("Warning: Memory allocation error\n");
  }
}

NPoint::NPoint(int d)
:dim(d)
{
  coord = new float[dim];
  if (coord==NULL) {
    printf("Warning: Memory allocation error\n");
  }
}

// Copy constructor
NPoint::NPoint(const NPoint& p)
{
  dim = p.dim;
  
  coord = new float[dim];
  memcpy(coord, p.coord, dim*sizeof(float));
}
   
// Destructor
NPoint::~NPoint()
{
  delete[] coord;
}

// Show the point
void NPoint::show()
{
  int j;
  
  for (j=0; j<dim; j++) {
    printf("%f ",coord[j]);
  }
}

void NPoint::show(FILE* fp)
{
  int j;
  
  for (j=0; j<dim; j++) {
    fprintf(fp,"%f ",coord[j]);
  }
}

// Set the value of a dimension
void NPoint::set_value(int d, float v)
{
  coord[d] = v;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -